网站大量收购独家精品文档,联系QQ:2885784924

jQuery开发基础第10章jQuery性能优化和 与技巧.ppt

jQuery开发基础第10章jQuery性能优化和 与技巧.ppt

  1. 1、本文档共35页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
jQuery开发基础第10章jQuery性能优化和 与技巧.ppt

6.检测浏览器 在jQuery1.9版本之前,检测浏览器类型使用如下方法: $(document).ready(function() { //检测火狐浏览器 if ($.browser.mozilla $.browser.version = 1.8 ){ } //检测Safari浏览器 if( $.browser.safari ){ } //检测Chrome浏览器 if( $.browser.chrome){ } //检测Opera浏览器 if( $.browser.opera){ } //检测IE6及以下版本浏览器 if ($.browser.msie $.browser.version = 6 ){ } //检测IE6以上版本浏览器 if ($.browser.msie $.browser.version 6){ } }); 但是,在jQuery1.9版本之后,$.browser已被剔除。因此要需要使用其他方式来检测浏览器, 具体代码如下: $.browser.mozilla = /firefox/.test(navigator.userAgent.toLowerCase()); $.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase()); $.browser.opera = /opera/.test(navigator.userAgent.toLowerCase()); $.browser.msie = /msie/.test(navigator.userAgent.toLowerCase()); 等号后面的表达式返回的是true或false,可以直接用来替换原来的$.browser.msie等。 检测是否为IE6: if(undefined == typeof(document.body.style.maxHeight)){} 检测是否为IE6-8: if(!$.support.leadingWhitespace){} 7.jQuery延时加载功能 $(document).ready(function() { window.setTimeout(function() { }, 1000); }); 8.预加载图片 $(document).ready(function() { jQuery.preloadImages = function() { for(var i = 0; iARGUMENTS.LENGTH; jQuery(?img { i++)).attr(src, arguments[i]); } } //使用方法 $.preloadImages(image1.jpg); }); 9.设置两列或者多列高度相同 $(document).ready(function() { function equalHeight(group) { tallest = 0; group.each(function() { thisHeight = $(this).height(); if(thisHeight tallest) { tallest = thisHeight; } }); group.height(tallest); } //使用方法 $(document).ready(function() { equalHeight($(.left)); equalHeight($(.right)); }); }); 10.动态控制页面字体大小 $(document).ready(function() { //重新设置页面字体大小 var originalFontSize = $(html).css(font-size); $(.resetFont).click(function(){ $(html).css(font-size, originalFontSize); }); //逐级递增字体大小 $(.increaseFont).click(function(){ var currentFontSize = $(html).c

您可能关注的文档

文档评论(0)

youngyu0329 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档