百度,淘宝,腾讯三大巨头HTML页面规范分解

本文探讨了HTML5在不同浏览器中的兼容性解决方案,包括使用html5shiv插件及X-UA-Compatible元标签,并介绍了移动设备上的视口设置方法。

【兼容html5方案】
百度贴吧,百度图片的实现

  1. <!--[if lt IE 9]>
  2. <script>
  3. (function(){
  4. var tags = ['header','footer','figure','figcaption','details','summary','hgroup','nav','aside','article','section','mark','abbr','meter','output','progress','time','video','audio','canvas','dialog'];
  5. for(var i=tags.length - 1;i>-1;i--){ document.createElement(tags[i]);}
  6. })();
  7. </script>
  8. <![endif]-->
  9. <style>
  10. header,footer,section,article,aside,nav,figure{display:block;margin:0;padding:0;border:0;}
  11. </style>

 

 

腾讯isux研究院的实现

  1. <!--[if lt IE 9]>
  2. <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  3. <![endif]-->

复制代码

淘宝- 我的淘宝页实现同上,只不过是不同版本

  1. <!-- [if lt IE 9]>
  2. <script src="http://g.tbcdn.cn//tb/mytaobao/12.12.15/common/??html5shiv-min.js"></script>
  3. <![endif]-->

复制代码

不得不提的一个插件 https://github.com/aFarkas/html5shiv 在github 上达到了3453 星的高度,获得了国内外的广泛认可,如果你厌烦了满页面的div 想尽早拥抱html5 元素,就使用它吧。

【兼容模式的选择】
关于兼容模式
百度首页使用的是

  1. <meta http-equiv=X-UA-Compatible content=IE=EmulateIE7>

复制代码


百度搜索页使用的是

  1. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

复制代码


百度图片,腾讯isux研究院,淘宝收藏页使用的是

  1. <meta http-equiv="X-UA-Compatible" content="IE=edge"/>

复制代码


X-UA-Compatible 这是个是IE8的专用标记,用来指定IE8浏览器去模拟某个特定版本的IE浏览器的渲染方式
chrome=1写法可以达到的效果是如果安装了GCF,则使用GCF来渲染页面,如果未安装GCF,则使用最高版本的IE内核进行渲染。

百度首页那么点东西他当然不在乎用哪种模式,更多地去照顾老式浏览器; 搜索页倾向于速度有GCF的时候更愿意使用chorme渲染。

不得不吐槽,国内各的银行支付时的兼容支持,由此第三种得到大家的共同认可似乎也无可厚非。


【移动至上】

腾讯isux研究院的实现

  1. <!-- Mobile Specific Metas
  2. ================================================== -->
  3. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no">
  4. <meta name="apple-mobile-web-app-capable" content="yes" />

复制代码

淘宝主页的实现

  1. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
  2. <meta content="yes" name="apple-mobile-web-app-capable" />

复制代码


这里没贴百度的,不代表百度不重视这一块,反而太重视了,19亿$买了91无线 再加上 百度App 贴吧App 音乐App 图片APP ... 全有了。

【建议升级】

  1. <!--[if lt IE 8]>
  2. <div class="g_tips">
  3. <p>已经有超过90%的用户使用更高版本 <a target="_blank" title="下载Chrome" href="http://www.google.com/chrome/">Google Chrome</a> 或 <a target="_blank" href="http://www.microsoft.com/zh-cn/download/ie.aspx?q=internet+explorer">Internet Explorer</a> 体验到了更精彩的页面,你还不试试?</p>
  4. </div>
  5. <![endif]-->
  6. <style>
  7. .g_tips{background:#FFF691;color:#010101;text-align:center;height:40px;line-height:40px;font-family:'STHeiti','5fae8f6f96c59ed1'}.g_tips a{color:#676767;padding:0 2px;zoom:1}
  8. </style>

复制代码

什么,连ie8都不是? 无法容忍啊,建议你早点换吧!

【参考模版】

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>页面名称</title>
  6. <meta name="keywords" content=""/>
  7. <meta name="description" content=""/>
  8. <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  9. <!-- Mobile Specific Metas
  10. ================================================== -->
  11. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no">
  12. <meta name="apple-mobile-web-app-capable" content="yes" />
  13. <!-- CSS
  14. ================================================== -->
  15. <link rel="shortcut icon" href="http://www.yunos.com/favicon.ico">
  16. <link rel="stylesheet" href="http://m.alicdn.com/css/index.css"/>
  17. <style>/* css */</style>
  18. </head>
  19.  
  20. <body>
  21. <!--[if lt IE 8]>
  22. <div class="g_tips">
  23. <p>
  24. 已经有超过90%的用户使用更高版本
  25. <a target="_blank" title="下载Chrome" href="http://www.google.com/chrome/">Google Chrome</a>
  26. <a target="_blank" href="http://www.microsoft.com/zh-cn/download/ie.aspx?q=internet+explorer">Internet Explorer</a>
  27. 体验到了更流畅更精彩的页面,你还不试试?
  28. </p>
  29. </div>
  30. <![endif]-->
  31.  
  32. <h1>300,000,00</h1>
  33.  
  34. <script src="js/index.js"></script>
  35. <script>// js
  36.   </script>
  37. </body>
  38. </html>

复制代码

<html lang="zh-CN"> 性属说明这个html内容是以中文为显示和阅读基础,多语言的网站建议添加。
通常情况下CSS放文档开始,脚本放在文档末尾我想不用解释太多
如果一个页面足够简单,写在页面上是完全 OK 的,特别是一些简单的专题,但是项目上需谨慎使用

页面全局变量命名随记 PDC FP PageInfo window.g_config (function(){window.PDC={}})();


【CDN加速】【dataUrl】【css spirte】【按需加载和loader机制】【压缩检查发布】
作为一个前端开发,这些你做了吗?

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值