使用VBScript的IE8中的兼容模式 [英] Compatibility Mode in IE8 using VBScript

查看:90
本文介绍了使用VBScript的IE8中的兼容模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用VBScript设置和检查IE8中的兼容模式?

Is it possible to set and check the Compatibility Mode in IE8 using VBScript?

推荐答案

按照定义文档兼容性一文,其中有 document.documentMode 属性,该属性返回IE8中当前页面的兼容模式.例如,您可以在IE8的地址"栏中键入此内容,以在消息框中显示兼容模式的值:

As per the Defining Document Compatibility article, there's the document.documentMode property that returns the compatibility mode of the current page in IE8. For example, you can type this into the IE8's Address bar to get the compatibility mode value displayed in a message box:

vbscript:msgbox(document.documentMode)

关于动态修改兼容模式...您可能可以遍历所有meta标记并更改X-UA-Compatible http-equiv标头的内容,如以下示例所示,但我没有IE 8所以不能说它是否真的有效.

As for modifying the compatibility mode dynamically... You could probably iterate through all meta tags and change the content of the X-UA-Compatible http-equiv header, like in the following example, but I don't have IE 8 so can't say if it actually works.

Sub ChangeCompatMode
  Dim metatags, meta

  Set metatags = document.getElementsByTagName("meta")
  For Each meta In metatags
    If UCase(meta.getAttribute("httpEquiv")) = "X-UA-COMPATIBLE" Then
      ' Change the document mode
      meta.setAttribute "content", "IE=edge"
      Exit For
    End If
  Next
End Sub

这篇关于使用VBScript的IE8中的兼容模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆