function addfavorite() { var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd': 'CTRL'; try{ if (document.al...
分类:
Web程序 时间:
2015-07-06 13:46:40
阅读次数:
183
navigator.userAgent.indexOf来判断浏览器类型<scriptlanguage="JavaScript"><!--functiongetOs(){varOsObject
="";if(navigator.userAgent.indexOf("MSIE")>0){return"MSIE";}if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){return"Firefox";}if(isS..
分类:
其他好文 时间:
2015-07-03 16:14:45
阅读次数:
113
字符串函数indexOf返回字符串中一个子串第一处出现的索引(从左到右搜索)。如果没有匹配项,返回 -1 。var index1 = a.indexOf("l");//index1 = 2var index2 = a.indexOf("l",3);//index2 = 3lastIndexOf返回字...
分类:
Web程序 时间:
2015-07-02 17:20:06
阅读次数:
217
function CloseWebPage(){ if (navigator.userAgent.indexOf("MSIE") > 0) { if (navigator.userAgent.indexOf("MSIE 6.0") > 0) { window.opener = null; windo...
分类:
Web程序 时间:
2015-07-02 13:33:18
阅读次数:
181
[?? 1, ????? ??]var num = 3223.98765;alert( num.toString().match(/^.*\.\d{2}/) || num );[?? 2, toPrecision? indexOf ??]var num = 3223.98765;alert( num...
分类:
其他好文 时间:
2015-07-01 13:41:25
阅读次数:
103
function GetCookieVal(offset)// 获得Cookie解码后的值{ var endstr = document.cookie.indexOf(";", offset); if (endstr == -1) endstr = document.cookie.length; ....
分类:
Web程序 时间:
2015-06-30 10:12:44
阅读次数:
163
JS自带函数concat将两个或多个字符的文本组合起来,返回一个新的字符串。var a = "hello";var b = ",world";var c = a.concat(b);alert(c);//c = "hello,world"indexOf返回字符串中一个子串第一处出现的索引(从左到右搜...
分类:
Web程序 时间:
2015-06-26 17:36:46
阅读次数:
171
①charAt(): 选中字符串内第几个元素 ②charCodeAt():字符串内,选中的那个元素的编码 ③String.fromCharCode():根据编码找出所对应的元素 ④ indexOf():找出元素对应的位置(从前往后找) ⑤lastIndexOf():找出元素对应的位置(从后往前...
分类:
编程语言 时间:
2015-06-25 17:04:32
阅读次数:
124
window.getRequest = function (url) { var theRequest = new Array(); if (url.indexOf("?") > -1) { var pair = url.substr(1).spl...
分类:
Web程序 时间:
2015-06-25 11:52:33
阅读次数:
126
字符串(String)字符串(String)使用长度属性length来计算字符串的长度:在字符串中查找字符串字符串使用 indexOf() 来定位字符串中某一个指定的字符首次出现的位置:实例var str="Hello world, welcome to the universe.";var n=s...
分类:
Web程序 时间:
2015-06-24 22:27:33
阅读次数:
163