当页面包含JavaScript时,如何避免IE消息栏

How to avoid IE message bar when page contains JavaScript?

本文关键字:何避免 IE 消息 面包 JavaScript      更新时间:2023-09-26

我正在尝试将以下代码插入到我的所有页面:

<script language="javascript">
    if (top.location == self.location)
    {
        top.location = '../index.html'
    }
</script>

当我有这个页面并尝试从IE 8运行该页面时,我会在页面顶部显示一个黄色条,要求我允许插件。

没有其他浏览器(firefox/opera/chrome/safari)能做到这一点。

每当有人访问页面时,点击这个按钮会很烦人。如何禁用此功能?

我只是希望我不必使用:

<!--[if !IE]>-->
<script language="javascript">
    if (top.location == self.location)
    {
        top.location = '../index.html'
    }
</script>
<!--<![endif]-->

我认为您谈论的是javascript的本地执行,所以请参阅本次讨论中关于web标记(MOTW)的答案:本地网页中的ActiveX内容,以及"网的标记";

有关更多信息,请参阅MSDN参考: