有没有办法使用JavaScript引入Internet Explorer条件注释?
|
我有一段HTML代码,其中包含条件注释:
<!--[if IE]>
<link rel=\"stylesheet\" ...>
<[endif]-->
此代码经过测试,在初始页面呈现时包含在页面的HEAD部分中时可以正常工作。
我想在Ajax响应中使用JavaScript向现有页面引入相同的条件CSS。
我试过了:
var comment = document.createComment(\"[if IE]>\\n<link rel=\\\"stylesheet\\\" ...>\\n<[endif]\");
Wicket.Head.addElement(comment); //this is framework code that just appends the element to the HEAD node of the page. I debugged and verified that it\'s doing the appendChild(...) call.
上面的代码不会将样式表应用于Internet Explorer7。是否可以使用JavaScript以Internet Explorer可以理解的方式引入条件样式?
为了清楚起见,我试图使用JavaScript创建条件样式,而不是尝试编写浏览器条件JavaScript。
没有找到相关结果
已邀请:
4 个回复
甲车劲
中使用条件注释,如下所示:
坍锭嘉韭蓝
娠侈脚惮顽
代替
!)
因此,您可以在CSS中执行此操作:
也可以使用javascript访问:
际恃啸称桅