javascript

UTF8编码转Unicode

function Utf8ToUnicode(strUtf8) { var bstr = ""; var nTotalChars = strUtf8.length; // total chars to be processed. var nOffset = 0; // processing point on strUtf8 var nRemainingBytes = nTotalChars; // how many bytes left to be converted var nOutputPosition = 0; var iCode, iCode1, iCode2; // the value of the unicode.while (nOffset < nTotalChars) { iCode = strUtf8.charCodeAt(nOffset); if ((iCode &...

根据URL获取主机名

function gethost(url) { var result = url.match("^http:\/\/([^\/:]*)"); if(result[1]) { var domain =...

获取一个页面元素在页面上的坐标位置

/* obj-要获取其页面坐标的元素 enjoy收集整理 http://www.9enjoy.com */function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { curleft = obj.offsetLeft curtop = obj.offsetTop while (obj = obj.offsetParent) { curleft += obj.offsetLeft curtop += obj.offsetTop } } return...

获取页面参数

function GetLocationParam(param){ //获取页面参数 var request = { QueryString : function(val) { var uri = window.location.search; var re = new RegExp("" +val+ "=([^&?]*)", "ig"); return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null); } } return request.QueryString(param); }js中就可以这样调用如URL为http://www.itlearner.com/test.htm?name=hxvar name=...

in_array – js模拟php中的in_array

in_arrayin_array -- 检查数组中是否存在某个值 说明 bool in_array ( mixed needle, array haystack [, bool strict] )在 haystack 中搜索 needle,如果找到则返回 TRUE,否则返回...

javascript计算小数保留两位小数,多位小数的方法

<SCRIPT LANGUAGE="JavaScript"> <!-- function formatFloat(src, pos) { return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos); }alert(formatFloat("1212.2323", 2)); //--> </SCRIPT>还有如下几种方法: var test=88888.234; alert(test.toFixed(2));...

批量去掉链接获得焦点时的虚线框

传统办法:在标签内加属性 代码多,修改难<a href="link1.htm" onfocus="this.blur()">link1</a><a href="link1.htm" onfocus="this.close()">link1</a><a href="link1.htm" hidefocus="true">link1</a><a href="link1.htm" hidefocus="hidefocus">link1</a>高级办法:遍历实现...