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.
但我的页面在一个HTML标记内呈现。只有在单击不同模板时内容才会发生变化。所以我无法在部分添加 。
Is there any way to add the <meta http-equiv="X-UA-Compatible" content="IE=edge">
using javascript
?
有没有办法使用javascript添加 ?
3 个解决方案
#1
38
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, or (of course) not to reply on X-UA-Compatible at all.
这里真正的答案必须是首先从服务器输出正确的标签,或者(当然)根本不回复X-UA-Compatible。
#2
15
$('head').append('<meta http-equiv="X-UA-Compatible" content="IE=Edge" /> ');
$('head')。append(' ');
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.
如果要为页面描述添加元数据标记,请使用DNN页面的“设置”添加“描述”和“关键字”。除此之外,修改HEAD时最好的方法是通过第三方模块将代码动态注入HEAD。
Found at http://www.dotnetnuke.com/Resources/Forums/forumid/7/threadid/298385/scope/posts.aspx
发现于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.
可以在页面设置>高级设置>页面标题标签中放置其他HEAD标签。
Found at http://www.dotnetnuke.com/Resources/Forums/forumid/-1/postid/223250/scope/posts.aspx
发现于http://www.dotnetnuke.com/Resources/Forums/forumid/-1/postid/223250/scope/posts.aspx
#3
3
Like this ?
像这样 ?
<script>
var meta = document.createElement('meta');
meta.setAttribute('http-equiv', 'X-UA-Compatible');
meta.setAttribute('content', 'IE=Edge');
document.getElementsByTagName('head')[0].appendChild(meta);
</script>
#1
38
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, or (of course) not to reply on X-UA-Compatible at all.
这里真正的答案必须是首先从服务器输出正确的标签,或者(当然)根本不回复X-UA-Compatible。
#2
15
$('head').append('<meta http-equiv="X-UA-Compatible" content="IE=Edge" /> ');
$('head')。append(' ');
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.
如果要为页面描述添加元数据标记,请使用DNN页面的“设置”添加“描述”和“关键字”。除此之外,修改HEAD时最好的方法是通过第三方模块将代码动态注入HEAD。
Found at http://www.dotnetnuke.com/Resources/Forums/forumid/7/threadid/298385/scope/posts.aspx
发现于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.
可以在页面设置>高级设置>页面标题标签中放置其他HEAD标签。
Found at http://www.dotnetnuke.com/Resources/Forums/forumid/-1/postid/223250/scope/posts.aspx
发现于http://www.dotnetnuke.com/Resources/Forums/forumid/-1/postid/223250/scope/posts.aspx
#3
3
Like this ?
像这样 ?
<script>
var meta = document.createElement('meta');
meta.setAttribute('http-equiv', 'X-UA-Compatible');
meta.setAttribute('content', 'IE=Edge');
document.getElementsByTagName('head')[0].appendChild(meta);
</script>