I want to add <meta http-equiv="X-UA-Compatible" content="IE=edge">
for a particular page.
But my pages are rendered inside one HTML
tag. Only the content is changing on clicking different templates. So i cannot add the <meta>
in <HEAD>
section.
Is there any way to add the <meta http-equiv="X-UA-Compatible" content="IE=edge">
using javascript
?
You can add it: var meta = document. createElement('meta'); meta. httpEquiv = "X-UA-Compatible"; meta.
The <meta> tag defines metadata about an HTML document. Metadata is data (information) about data. <meta> tags always go inside the <head> element, and are typically used to specify character set, page description, keywords, author of the document, and viewport settings.
To use JavaScript to change the meta tags of the page, we can set the properties that are available in a meta element. and set its content attribute value. and set its content attribute value.
You can add it:
var meta = document.createElement('meta'); meta.httpEquiv = "X-UA-Compatible"; meta.content = "IE=edge"; document.getElementsByTagName('head')[0].appendChild(meta);
...but I wouldn't be surprised if by the time that ran, the browser had already made its decisions about how to render the page.
The real answer here has to be to output the correct tag from the server in the first place. (Sadly, you can't just not have the tag if you need to support IE. :-| )
$('head').append('<meta http-equiv="X-UA-Compatible" content="IE=Edge" />');
or
var meta = document.createElement('meta'); meta.httpEquiv = "X-UA-Compatible"; meta.content = "IE=edge"; document.getElementsByTagName('head')[0].appendChild(meta);
Though I'm not certain it will have an affect as it will be generated after the page is loaded
If you want to add meta data tags for page description, use the SETTINGS of your DNN page to add Description and Keywords. Beyond that, the best way to go when modifying the HEAD is to dynamically inject your code into the HEAD via a third party module.
Found at http://www.dotnetnuke.com/Resources/Forums/forumid/7/threadid/298385/scope/posts.aspx
This may allow other meta tags, if you're lucky
Additional HEAD tags can be placed into Page Settings > Advanced Settings > Page Header Tags.
Found at http://www.dotnetnuke.com/Resources/Forums/forumid/-1/postid/223250/scope/posts.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With