设为首页 收藏本站
查看: 997|回复: 0

[经验分享] 在IIS上解决IE8兼容性视图问题

[复制链接]

尚未签到

发表于 2015-8-15 02:07:18 | 显示全部楼层 |阅读模式
  Any users accessing your site using the Internet Explorer 8 (IE8) browser ( currently in Beta ) will typically not get a very good rendering experience if your site was designed for Internet Explorer 7 (IE7) because of new standards that IE8 is supporting around HTML and CSS formats. There are two ways to resolve this.
1) The longer term option is to re-write your web application to render IE8 correctly - However this would not be my first choice.
2) The best ( to choose first off ) is to instruct any IE8 browsers to browse your site in IE7 emulation mode so that the current rendering is maintained. How do you do this? Simple
  On a Per-site basis, site owners and administrators can include the following custom HTTP header to force Internet Explorer 8 to render Web pages like Internet Explorer 7:
  
X-UA-Compatible: IE=EmulateIE7
  
  To add a custom HTTP response header at the Web site level in Internet Information Services 7 on a Windows Server 2008-based computer, follow these steps:


  • Click Start, click Administrative Tools, and then click Internet Information Services (IIS) Manager.
  • Under Connections, double-click the server that you want, and then double-click Sites.
  • Click the Web site where you want to add the custom HTTP response header.
  • Under Web site name Home, double-click HTTP Response Headers in the IIS section.
    Note In this step, Web site name is the name of the Web site.
  • Under Actions, click Add.
  • In the Name box, type X-UA-Compatible.
  • In the Value box, type IE=EmulateIE7.
  • Click OK.
  You can also modify the IIS7 configuration file with the following details ( or you can check the config after the changes made above )
  <system.webServer>
<httpProtocol>
    <customHeaders>
  <add name="X-UA-Compatible" value="IE=EmulateIE7" />
  </customHeaders>
  </httpProtocol>
</system.webServer>
  To add a custom HTTP response header at the Web site level in Internet Information Services 6 and earlier versions, follow these steps:


  • Click Start, click Run, type inetmgr.exe, and then click OK.
  • Expand the server that you want, and then expand Web Sites.
  • Right-click the Web site that you want, and then click Properties.
  • Under Custom HTTP headers, click Add.
  • In the Custom header name box, type X-UA-Compatible.
  • In the Custom header value box, type IE=EmulateIE7.
  • Click OK two times.

Per-page basis
Site owners and administrators can include the following special HTML tag after the <Head> tag on the page:  
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
  
  The following example shows use of this Internet Explorer 7 compatibility mode tag on a per-page basis:
  
<html> <head> <!-- Use IE7 mode --> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <title>My Web Page</title> </head> <body> <p>Content goes here.</p> </body> </html> 最后我说一个需要注意的问题:建议在网站每个网页上加上DTD标识表示该网页支持XHTML规范:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">因为在路由器上使用内网服务器地址转换服务后(将内网服务器IP和端口映射为路由器的外网IP和端口,供外网使用者通过路由器IP访问内网服务器),我发现没有用DTD标识的页面不管是在IIS上加X-UA-Compatible IE=EmulateIE7 HTTP头,还是在页面上加<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 都不起作用,IE上始终有兼容性视图按钮,但是我用内网访问服务器就没有,最后发现有兼容性视图按钮的情况是使用公司网站域名来访问网站,言下之意就是通过外网来访问公司服务器经过了路由器进行了地址转换,最后我将所有页面都加上了DTD标识,果然从域名访问网站时兼容性视图按钮不见了。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-99065-1-1.html 上篇帖子: SPS安装过程中配置服务器场帐户设置页面不能正常显示以及IIS中SPS管理站点未配置成功问题的原因 下篇帖子: IIS 服务器下载apk文件报404错
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表