![](/img/trans.png)
[英]Website with javascript doesn't work in IE9 but in IE9's compatibility mode - how to force compatibility view?
[英]Force IE9 into compatibility mode using javascript
我有一個框架需要兼容模式,但父框架似乎是設置它所以框架內的以下標簽什么都不做。
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
無論如何,只有將compat模式應用於幀,或者讓幀將compat模式應用於父幀。
正在考慮是否有一個javascript方法來切換模式我可以將它從子框架應用到父框架。
所以這就是我收集的內容。
唯一可行的是元標記方式。
但是,它似乎不適用於幀,因為IE9禁用了一幀與另一幀不同的能力。
元標記也不能在腳本或鏈接標記之前,只有我注意到的其他元標記,否則它也會失敗。
測試用例:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Test test</title>
<meta name="keywords" content="keywords, keyword, keyword phrase, etc.">
<!--<link href="test.css" rel="stylesheet" type="text/css" />-->
<!--<script type="text/javascript">alert('test');</script>-->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
</head>
<body>
inline-block <div style="display:inline-block">test</div>
</body>
</html>
從頭頂你可以嘗試創建元標記並將其插入父框架頭部。 我不確定這是否會強制進行仿真。
var meta = document.createElement('meta');
meta.setAttribute('http-equiv', 'X-UA-Compatible');
meta.setAttribute('content', 'IE=EmulateIE7');
parent.document.getElementsByTagName('head')[0].appendChild(meta);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.