地址本在不同手机间的迁移
2012-06-12 17:04
141 查看
今天切一个专题页,页面比较长,想在右下角加一个返回头部的按钮。
一开始模仿w3cplus.com用了普通的锚点定位,代码如下:
发现在ie6底下,居然错位,跑到左下角去了,心想,应该不会呀,这个网站都是这样搞滴,于是用ie打开,崇拜已久的w3cplus网站,它的网站居然没有考虑到ie6,用的都是新技术。哎,没办法,只能自己来了。
···插曲:以前在公司只要测IE6,7,8,9,ff,谷歌,现在做国内站,除了这些主流的,还得测,360,搜狗,遨游,safari,苹果。。天哪。兼容性问题,像360这样变态的浏览器,似IE内核又不是IE内核,头疼哪。。
回到正题。。
于是,朋友建议用了jquery,毕竟用ie hack定位,不太好,其实我目前还不是很喜欢js,毕竟不是自己写的代码,都是调用的,如果遇到问题,解决不了,那岂不是很糗,于是一直在恶补js,那本厚厚的js权威指南,一番就犯困,太概念性了,还是得实践实践在实践,我相信几个月之后会有突破的。
一开始一直无效果,原来是js加载顺序的问题,ohmygod,超想屎的。现在ok了,ie6下也行,明天去看看那些国内其他浏览器的效果。
方法如下:
1,调用jquery的官方类库。。传说中jquery-1.3.1.js这个最好用,我个人不喜欢过时的东西。。
2,调用一个别人写的gototop的js。。(谁来解释一下)
3,在html页面中引用
求解:还有没有更好,更简单的办法啊。。
本文出自 “王宁” 博客,请务必保留此出处http://wswangning1988.blog.51cto.com/1432465/691588
一开始模仿w3cplus.com用了普通的锚点定位,代码如下:
<div id="goToTop"> <a title="回到顶部" href="#">TOP</a> </div>
#goToTop { bottom: 5px; position: fixed; right: 5px; z-index: 9000; }
发现在ie6底下,居然错位,跑到左下角去了,心想,应该不会呀,这个网站都是这样搞滴,于是用ie打开,崇拜已久的w3cplus网站,它的网站居然没有考虑到ie6,用的都是新技术。哎,没办法,只能自己来了。
···插曲:以前在公司只要测IE6,7,8,9,ff,谷歌,现在做国内站,除了这些主流的,还得测,360,搜狗,遨游,safari,苹果。。天哪。兼容性问题,像360这样变态的浏览器,似IE内核又不是IE内核,头疼哪。。
回到正题。。
于是,朋友建议用了jquery,毕竟用ie hack定位,不太好,其实我目前还不是很喜欢js,毕竟不是自己写的代码,都是调用的,如果遇到问题,解决不了,那岂不是很糗,于是一直在恶补js,那本厚厚的js权威指南,一番就犯困,太概念性了,还是得实践实践在实践,我相信几个月之后会有突破的。
一开始一直无效果,原来是js加载顺序的问题,ohmygod,超想屎的。现在ok了,ie6下也行,明天去看看那些国内其他浏览器的效果。
方法如下:
1,调用jquery的官方类库。。传说中jquery-1.3.1.js这个最好用,我个人不喜欢过时的东西。。
2,调用一个别人写的gototop的js。。(谁来解释一下)
jQuery.fn.floatdiv=function(location){ var isIE6=false; var Sys={}; var ua=navigator.userAgent.toLowerCase(); var s; (s=ua.match(/msie ([\d.]+)/))?Sys.ie=s[1]:0; if(Sys.ie&&Sys.ie=="6.0"){isIE6=true;} var windowWidth,windowHeight; if(self.innerHeight){ windowWidth=self.innerWidth; windowHeight=self.innerHeight; } else if(document.documentElement&&document.documentElement.clientHeight){ windowWidth=document.documentElement.clientWidth; windowHeight=document.documentElement.clientHeight; }else if(document.body){ windowWidth=document.body.clientWidth; windowHeight=document.body.clientHeight; } return this.each(function(){ var loc; var wrap=$("<div></div>"); var top=-1; if(location==undefined||location.constructor==String){ switch(location){ case("rightbottom"): loc={right:"0px",bottom:"0px"}; break; case("leftbottom"): loc={left:"0px",bottom:"0px"}; break; case("lefttop"): loc={left:"0px",top:"0px"}; top=0; break; case("righttop"): loc={right:"0px",top:"0px"}; top=0; break; case("middletop"): loc={left:windowWidth/2-$(this).width()/2+"px",top:"0px"}; top=0; break; case("middlebottom"): loc={left:windowWidth/2-$(this).width()/2+"px",bottom:"0px"}; break; case("leftmiddle"): loc={left:"0px",top:windowHeight/2-$(this).height()/2+"px"}; top=windowHeight/2-$(this).height()/2; break; case("rightmiddle"): loc={right:"0px",top:windowHeight/2-$(this).height()/2+"px"}; top=windowHeight/2-$(this).height()/2; break; case("middle"): var l=0; var t=0; l=windowWidth/2-$(this).width()/2; t=windowHeight/2-$(this).height()/2; top=t; loc={left:l+"px",top:t+"px"}; break; default: location="rightbottom"; loc={right:"0px",bottom:"0px"}; break; } }else{ loc=location; var str=loc.top; if(typeof(str)!='undefined'){ str=str.replace("px","");top=str; } } if(isIE6){ if(top>=0){ wrap=$("<div style=\"top:expression(documentElement.scrollTop+documentElement.clientHeight /2-this.offsetHeight/2);\"></div>"); } else{ wrap=$("<div style=\"top:expression(documentElement.scrollTop+documentElement.clientHeight-this.offsetHeight);\"></div>"); } } $("body").append(wrap);wrap.css(loc).css({position:"fixed",z_index:"999"}); if(isIE6){ wrap.css("position","absolute"); $("body").css("background-attachment","fixed").css("background-image","url(n1othing.txt)"); } $(this).appendTo(wrap); }); };
3,在html页面中引用
<script> (function(){ var lc = $('#goToTop'); lc.floatdiv('rightbottom'); })() </script>
求解:还有没有更好,更简单的办法啊。。
本文出自 “王宁” 博客,请务必保留此出处http://wswangning1988.blog.51cto.com/1432465/691588
相关文章推荐
- 地址本在不同手机间的迁移
- Filter过滤器实现同一地址手机和电脑页面不同
- 移动端不同分辨率手机的适配问题
- svn服务器上不同仓库下的项目迁移并保持历史记录
- 根据不同访问设备跳转到PC页面或手机页面
- shiro控制不同模块登录地址
- js 实现在移动端开发,解决不同手机像素大小的兼容问题
- Oracle在不同平台间表空间迁移
- Android程序对不同手机屏幕分辨率自适应的总结
- sqlServer数据库实现不同库之间表迁移
- oracle 数据泵迁移不同表空间数据
- Iphone6手机不同浏览器页面尺寸设计
- 一个很好的blog地址,关于手机测试(appium\ Robotium等 )
- 服务器迁移php版本不同可能诱发的问题
- pc手机&姓名&地址验证&input提示文案兼容ie
- 相同线性地址到不同物理地址的转换(个人心得)
- java后台判断客户端是手机/PC并返回不同页面
- 微信公众平台Java开发如何让网页自适应不同分辨率的手机浏
- Android不同手机屏幕分辨率自适应
- windows和虚拟机ubuntu栈地址扩展的不同