几个有用的js函数
2011-05-06 12:46
465 查看
1.获取URL中的值
2.让火狐支持innerText
待续..
function GetRequest() { var url = location.search; //获取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); } } return theRequest; } //使用方法 function use(){ var Request = new Object(); Request = GetRequest(); alert(Request["salse"]); }
2.让火狐支持innerText
(function(bool) { function setInnerText(o, s) { while (o.childNodes.length != 0) { o.removeChild(o.childNodes[0]); } o.appendChild(document.createTextNode(s)); } function getInnerText(o) { var sRet = ""; for (var i = 0; i < o.childNodes.length; i++) { if (o.childNodes[i].childNodes.length != 0) { sRet += getInnerText(o.childNodes[i]); } if (o.childNodes[i].nodeValue) { if (o.currentStyle.display == "block") { sRet += o.childNodes[i].nodeValue + "n"; } else { sRet += o.childNodes[i].nodeValue; } } } return sRet; } if (bool) { HTMLElement.prototype.__defineGetter__("currentStyle", function() { return this.ownerDocument.defaultView.getComputedStyle(this, null); }); HTMLElement.prototype.__defineGetter__("innerText", function() { return getInnerText(this); }) HTMLElement.prototype.__defineSetter__("innerText", function(s) { setInnerText(this, s); }) } })(/Firefox/.test(window.navigator.userAgent));
待续..
相关文章推荐
- ASP中有关字符编码转换的几个有用函数
- JS操作Cookies的几个实用方便的函数
- PHP中几个有用的函数
- php使用中碰到的几个有用的函数
- js 常用到的几个数学函数
- 几个非常有用SQL Server的函数(SQL Server的函数的使用)
- 几个js验证函数
- [DES] 可能有用的几个加密解密函数,先放着,调查完再来看
- js中几个正则表达式相关函数使用时g标志的作用
- SQL Server 中几个有用的特殊函数
- js 动态添加标签(新增一行,其实很简单,就是几个函数的应用)
- html调用js变量和函数的几个方法
- JS(二十一)有用的JS函数(持续更新)
- PHPCMS几个有用的全局函数
- 学习PHP动态网页技术收集的几个有用函数
- 这几个函数可能有用:last_day(), add_months()...
- JavaScript 数组几个比较有用的函数
- c里常见的几个有用的函数总结
- VB下几个非常有用的函数
- SQL Server 中几个有用的特殊函数