Javascript 通过jquery添加元标记?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7063863/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 00:40:45  来源:igfitidea点击:

Adding a meta tag via jquery?

javascriptjqueryinternet-explorer-7

提问by PD24

I need to add this meta-tag in the head section of the page as i need the page to force IE7.

我需要在页面的头部部分添加这个元标记,因为我需要页面来强制 IE7。

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

I am using DNN 5.6

我正在使用 DNN 5.6

How can i do this?

我怎样才能做到这一点?

回答by Scott Brown

$('head').append('<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> ');

$('head').append('<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> ');

Though I'm not certain it will have an affect as it will be generated after the page is loaded

虽然我不确定它会产生影响,因为它会在页面加载后生成

-- edit --

- 编辑 -

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

如果幸运的话,这可能允许使用其他元标记

-- edit 2 --

-- 编辑 2 --

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

回答by Saul

There is really no use in adding <meta>headers after the page has loaded.

<meta>在页面加载后添加标题确实没有用。

To force IE7 rendering, change the underlying HTML.

要强制 IE7 呈现,请更改底层 HTML。