随笔分类 - Javascript
摘要:<div id="test_chg">Look At Me,<a href="javascript:gogo();void(0)">Change me</a>!<br /><span id="curcss"></span></div><script language="javascript">var g={ E:function (c) { if (typeof c === "string") { r
阅读全文
摘要:screenX:鼠标在显示屏幕上的坐标。clientX:鼠标在页面显示区域的坐标。注:以上两个都是各浏览器通用的。pageX:FF特有,鼠标在页面上的位置,从页面左上角开始定位,这个可以很方便在整个页面上进行定位,IE没有直接替换的属性。layerX:FF特有,鼠标相对于“触发事件的元素的层级关系中离该元素最近的,设置了position的父元素”的边界的位置,从border的左上角开始定位,即如果这个父元素存在border,则坐标原点在border的左上角,而不是内容区域的左上角。offsetX:IE特有,鼠标相对于“触发事件的元素”的位置,从内容区域左上角开始定位,不是从border左上角开
阅读全文
摘要://查找值是否存在,存在返回位置,否则返回-1 Array.prototype._in=function(find) { for (i = 0; i < this.length; i++) { if (find==this[i]) return i; } return -1; } //删除指定索引位置的成员 Array.prototype._removeAt=function(idx) { var tmp=this.sl...
阅读全文
摘要:function getwh(e){ var a=new Array() var t=e.offsetTop; var l=e.offsetLeft; var w=e.offsetWidth; var h=e.offsetHeight; while(e=e.offsetParent){ t+=e.offsetTop; l+=e.offsetLeft; } a[0]=w;a[1]=h return a;
}ie 9,8,7,6 ff 7 8工作都正常,不错的代码
阅读全文
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=u
阅读全文
摘要:<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>获取某个城市的经度纬度</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script>
&l
阅读全文
摘要:<script language="javascript">function killErrors(){ try{tmp="";for(var i=0;i<arguments.length)tmp+=i+":"+arguments[i]+"<br/>";alert(tmp);}catch(e){}return true;} window.onerror = killErrors; function displayErrorMsg(e){tmp="<hr>"
阅读全文
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb23
阅读全文
摘要:function setCookie(name, value, isForever) {document.cookie = name + "=" + escape(value) + ";domain=mail.163.com" + (isForever?";expires="+ (new Date(2099,12,31)).toGMTString():"");}function getCookie(name) { var search = name + "=" if(document.cooki
阅读全文
摘要:<body> <script language="JavaScript"> function getCursorPos(event) { var obj= event.target||event.srcElement; if(document.selection){ if(obj.tagName!=undefined&&obj.tagName=='INPUT'){ var s=document.selection.createRange(); s.setEndPoint("StartToStart"
阅读全文
摘要:JS:function divideContent(contentDomId,linkDomId){var maxCotentHeight = 600;var lineheight = parseInt(document.getElementById(contentDomId).style.lineHeight);maxCotentHeight = Math.ceil(maxCotentHeight/lineheight)*lineheight;document.getElementById(contentDomId).style.height = "";var conte
阅读全文
摘要:准备:1、prototype.js,http://prototype.conio.net/,用于ajax加载汉字字库2、汉字字库http://cn.minidx.com/index.php?option=com_docman&task=doc_download&gid=47----------------------------------------------------------------------------------------------------------------------------------------------<!DOCTYPE
阅读全文
摘要:functionsptOps(str)...{varurl='/product/index/sa?'+str;varelement=document.createElement("script");element.setAttribute("language","javascript");element.setAttribute("src",url);document.body.appendChild(element);}实际就是把iframe换成script而已,效率高,代码简单,兼容性好
阅读全文
摘要://JavaScriptDocument/**//**@paramact:1全选,2反选*@paramdom:checkbox名称*selectct记录被选中的数量*可以传入参数三和参数四;表示checkbox参数三属性值等于参数四时才进行全选、反选,否则跳过。*/varselectct=0;functiondoselect(act,dom)...{selectct=0;varobj=document.getElementsByTagName('input');for(vari=0;i<obj.length;i++)...{if(obj[i].type=='che
阅读全文
摘要:if(typeof(Class)=='undefined')...{varClass=...{create:function()...{returnfunction()...{this.initialize.apply(this,arguments);}}}}varStrR=function(str,len)...{varStr="";for(vari=0;i<len;i++)Str+=str;returnStr;}/**//**Itisafunctionhassimilarfunctionof PHPfunctionvar_dump*@usage:v
阅读全文
摘要:/**//**getallnodes'sattributeandtext*/functiongetAT(nodes)...{varXMLData=[];for(vari=0;i<nodes.length;i++)...{varcrtNode=...{};crtNode.$name=nodes[i].nodeName;if(nodes[i].attributes)...{for(varj=0;j<nodes[i].attributes.length;j++)...{debug.innerHTML+='<i>'+nodes[i].attributes
阅读全文

浙公网安备 33010602011771号