1varver="IE6";
2if(window.XMLHttpRequest)
3ver=(!window.ActiveXObject)?"MozillaorSafari":"IE7";
4returnver;
2、获取位置,在firefox中,无法使用object.style.pixelLeft,只能用object.style.left (top一样) ,object.style.left 返回值是带有单位的,这里假设单位是(px),如下为获取位置的函数
1functiongetPos(obj)
2{
3varp=newfunction(){this.left;this.top;};
4p.left=parseInt(obj.style.left.slice(0,-2),10);
5p.top=parseInt(obj.style.top.slice(0,-2),10);
6returnp;
7}
8varpos=getPos(document.getElementById("111"));
9alert("left:"+pos.left+"\ntop:"+pos.top);
3、透明度设置不同
1functionsetOpcity(obj,value){
2//alpha(opacity=50)仅被IE支持
3if(isMSIE){
4obj.style.filter="alpha(opacity="+value+")";
5}else{
6obj.style.MozOpacity=value*0.01;
7}
8}
4、禁止文本选择的方法
1、判断浏览器类型
1varver="IE6";
2if(window.XMLHttpRequest)
3ver=(!window.ActiveXObject)?"MozillaorSafari":"IE7";
4returnver;
2、获取位置,在firefox中,无法使用object.style.pixelLeft,只能用object.style.left (top一样) ,object.style.left 返回值是带有单位的,这里假设单位是(px),如下为获取位置的函数
1functiongetPos(obj)
2{
3varp=newfunction(){this.left;this.top;};
4p.left=parseInt(obj.style.left.slice(0,-2),10);
5p.top=parseInt(obj.style.top.slice(0,-2),10);
6returnp;
7}
8varpos=getPos(document.getElementById("111"));
9alert("left:"+pos.left+"\ntop:"+pos.top);
3、透明度设置不同
1functionsetOpcity(obj,value){
2//alpha(opacity=50)仅被IE支持
3if(isMSIE){
4obj.style.filter="alpha(opacity="+value+")";
5}else{
6obj.style.MozOpacity=value*0.01;
7}
8}
4、禁止文本选择的方法
1<script>
2document.onselectstart=function(){returnfalse;}//这个函数是对ie,为ff时使用css来控制
3</script>
4<style>
5/*下面这个css是firefox防止选择的,firefox没有onselectstart事件*/
6body
7{
8-moz-user-focus:ignore;
9-moz-user-input:disabled;
10-moz-user-select:none;
11}
12
13</style>
优质内容筛选与推荐>>
1、CF1059C Sequence Transformation2、第六章 支持向量机3、Linux安装mysql4、使用ANTLR进行命令行参数解析5、cookie和session机制
长按二维码向我转账
受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。
阅读
好看
已推荐到看一看
你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
取消
分享想法到看一看
确定
最多200字,当前共字
微信扫一扫
关注该公众号