【杂记】(获取地址栏内容、判断是否安装了flash、判断浏览器、判断是否为ie浏览器、font字体、文字对齐、鼠标禁止点击、浏览器设置字体编码、浏览器兼容问题、查找元素(这个以后的元素都删除))

mac2024-04-05  35

1. 获取地址栏内容

http://localhost:9096/shared/livestream/textindex?gradedesc=all&bookletdesc=all&status=05,10&keyword=yyhh window.location.href (在浏览器中就是完整的地址栏) window.location.protocol---------URL 的协议部分 http: window.location.host----------URL 的主机部分 localhost window.location.port-----URL 的端口部分 :9096 window.location.pathname (URL 的路径部分(就是文件地址))/shared/livestream/textindex window.location.search-------查询(参数)部分 ?gradedesc=all&bookletdesc=all&status=05,10&keyword=yyhh window.location.hash-------锚点

2. 判断是否安装了flash

var isIE = !-[1,]; if(isIE){ try{ var swf1 = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); alert('安装了Flash'); } catch(e){ alert('没有安装Flash'); } } else { try{ var swf2 = navigator.plugins['Shockwave Flash']; if(swf2 == undefined){ alert('没有安装Flash'); } else { alert('安装了Flash'); } } catch(e){ alert('没有安装Flash'); } }

3. 判断浏览器

function getOs() { if(isIE=navigator.userAgent.indexOf("MSIE")>0) { return "MSIE"; //ie浏览器 } if(isChrome=navigator.userAgent.indexOf("Chrome")>0){ return "chrome"; //Chrome浏览器 } if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ return "Firefox"; //Firefox浏览器 } if(isOpera=navigator.userAgent.indexOf("Opera")>0) { return "Opera"; //Opera浏览器 } if(isSafari=navigator.userAgent.indexOf("Safari")>0) { return "Safari"; //Safari浏览器 } if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){ return "Gecko"; } } alert(navigator.userAgent); alert("您的浏览器类型为:"+getOs());

4. 判断是否为ie浏览器

function isIE(){ if (window.navigator.userAgent.indexOf("MSIE")>=1) { return true; }else{ return false; } } function isIE() { if (!!window.ActiveXObject || "ActiveXObject" in window){ return true; }else{ return false; } } alert(isIE());

5. 字体

font: 14px/1.5 "Helvetica Neue",Helvetica,Arial, "Microsoft Yahei","Hiragino Sans GB","Heiti SC", "WenQuanYi MicroHei",sans-serif; 6. 居中为啥不居中 在父级元素中添加display:flex即可

7. 文字参差不齐 text-align:justify; text-justify:inter-ideograph;

8. 判断帮助文档类型

var _url = window.location.search; var _wkzjapp = "?type=117"; var _wkb = "?type=118"; var _wkzj = "?type=119"; var _hdjx = "?type=120"; switch(_url){ case _wkzjapp: $("nav .nav1").show(); break; case _wkb: $("nav .nav2").show(); break; case _wkzj: $("nav .nav3").show(); break; case _hdjx: $("nav .nav4").show(); break; } 除了这个以后的元素都删除 $("#fullPage-nav li").eq(5).next().nextAll().remove();

10. css鼠标禁止点击事件

pointer-events:none/auto $('body').css('pointer-events','none');//屏蔽点击 $('body').css('pointer-events','auto')//恢复默认

11. 浏览器设置字体编码

新细明体PMingLiU\65B0\7EC6\660E\4F53细明体MingLiU\7EC6\660E\4F53标楷体DFKai-SB\6807\6977\4F53黑体SimHei\9ED1\4F53宋体SimSun\5B8B\4F53新宋体NSimSun\65B0\5B8B\4F53仿宋FangSong\4EFF\5B8B楷体KaiTi\6977\4F53仿宋_GB2312FangSong_GB2312\4EFF\5B8B_GB2312楷体_GB2312KaiTi_GB2312\6977\4F53_GB2312微软正黑体Microsoft JhengHei\5FAE\x8F6F\6B63\9ED1\4F53微软雅黑Microsoft YaHei\5FAE\8F6F\96C5\9ED1

12. 【火狐兼容问题】高度

js设置了高度自适应,但是页面的高度盒子撑不起来,这个时候要设置body的盒子,width:100%;height:100%;盒子就撑起来了。 13. 【火狐兼容问题】字体 在火狐浏览器标签下的字体大小为1px,所以要单独给i定义字体大小。 14. 【火狐兼容问题】多行文本省略 其他浏览器均能正常的显示效果,而火狐不行,就必须给他高度。 15. 【safari兼容】border-radius safari的border-radius兼容是border边框的影响,其余没问题

最新回复(0)