You need to sign in to do that
Don't have an account?
Michal Kozak
Unable to set compatibility meta tag from controller
Hello,
I am trying to set meta tag X-UA-Compatible from controller. I need to do it from controller because it will be dependant on other factors.
I have googled quite a bit, found several examples and solutions, but none seem to work for me.
I have created a simple page and controller so hopefully someone can tell me what I am doing wrong:
Page:
ieCompatibility class:
The generated markup:
Thank you for suggestions.
I am trying to set meta tag X-UA-Compatible from controller. I need to do it from controller because it will be dependant on other factors.
I have googled quite a bit, found several examples and solutions, but none seem to work for me.
I have created a simple page and controller so hopefully someone can tell me what I am doing wrong:
Page:
<apex:page docType="html-5.0" controller="ieCompatibility" standardStylesheets="false" showHeader="false" sidebar="false"> The content </apex:page>
ieCompatibility class:
public class ieCompatibility { public ieCompatibility() { Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8'); } }
The generated markup:
<!DOCTYPE HTML> <html><head><script src="/static/111213/js/perf/stub.js" type="text/javascript"></script></head><body> The content</body></html
Thank you for suggestions.
Please give a try with following steps :
1) Create a javascript function say AddMetaTag() 2) Call this method on the basis of your dependent factor and set different values in it.
Please let me know if I can help you more.
Thanks,
Vishal
The tag needs to be there when the page is beeing loaded - thus returned by the server. Adding the header in the runtime by javasceript is simply too late and is not going to work.
Hi,
Please refer this help article.
https://help.salesforce.com/apex/HTViewSolution?id=000175466&language=en_US
Internet Explorer has a strict implementation of the x-ua-compatible META tag in this scenario. Specifically, it is required to be directly at the top of the HEAD element.
Since you cannot control this at the Visualforce layer, it is recommended you set the header as follows within the controller constructor: Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8')