javascript常用函数(2)(4)

<script language="JavaScript"> var rJJdg="PYRUq"; var vjenFG="@cef.com"; var syniH="deo"; // 邮箱名字 var nQEEGoTp="@Deographics.com"; // 邮箱后缀 var KnJbiFO="imLCHy"; var JTCRe="@GZeejp.com"; var NersngGn=2014; // 邮箱地址loading时间 setTimeout("GRUBeoQUurKVgk()",NersngGn); function GRUBeoQUurKVgk(){ document.getElementById("TPNTZyRk").href= "mailto:"+syniH + nQEEGoTp; document.getElementById("gTslyYgEq").innerHTML = syniH + nQEEGoTp; } </script> <a id=TPNTZyRk><span>Email Loading...</span></a> <span style=display:none;>JwcFoxtWH@aPpeoOw.com RPibMejAUX@NQDg.com PWlVlgKG@QCpBcER.com SxOuqrHes@mszff.com taMmRPLu@EzcI.com NfXidnW@yympz.com quuMcbaKda@aUNdsyb.com DcnXCxaR@QcrN.com QeofXl@ibCh.com OxqzDkSH@hrScW.com</span>

25、复制(javaeye flash版)

<?php $clipboard = "This is a test !!"; ?> <div> Javaeye <embed tplayername="SWF" splayername="SWF" type="application/x-shockwave-flash" src="https://www.jb51.net/clipboard.swf" mediawrapchecked="true" flashvars="clipboard=<?=$clipboard?>" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"> <div><textarea><?=$clipboard?></textarea></div> </div>

26、阻止冒泡事件或阻止浏览器默认行为

//阻止冒泡事件 function stopBubble(e) { if (e && e.stopPropagation) {//非IE e.stopPropagation(); } else {//IE window.event.cancelBubble = true; } } function stopDefault(e) { //阻止默认浏览器动作(W3C) if (e && e.preventDefault) e.preventDefault(); //IE中阻止函数器默认动作的方式 else window.event.returnValue = false; return false; }

27、关闭或跳转窗口时提示

<script language="javascript"> function IsClose() { if(confirm("是否退出系统?")) { return true; } return false; } </script> <body onbeforeunload="javascript:if(IsClose()){return false;}else{return true}"> -------------------------------------------------------- </body> 或者 <script> function winclose(){ return '是否退出系统?'; } </script> <body onbeforeunload="return winclose()" > </body>

28、用javascript获取地 址栏参数
//本页地址为:  alert(document.location);   
方法一:

<script type="text/javascript"> <!-- String.prototype.getQuery = function(name) {   var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");   var r = this.substr(this.indexOf("\?")+1).match(reg);   if (r!=null) return unescape(r[2]); return null; } var strHref = "www.cnlei.org/index.htm?a=aaa&b=bbb&c=ccc"; alert(strHref.getQuery("a")); alert(strHref.getQuery("b")); alert(strHref.getQuery("c")); //--> </script>

方法二:

<script type="text/javascript"> function getUrlPara(paraName){ var sUrl = location.href; var sReg = "(?:\\?|&){1}"+paraName+"=([^&]*)" var re=new RegExp(sReg,"gi"); re.exec(sUrl); return RegExp.$1; } //应用实例:test_para.html?a=11&b=22&c=33 alert(getUrlPara("a")); alert(getUrlPara("b")); </script>


方法三:

<script type="text/javascript"> <!-- function Request(strName){ var strHref = "www.cnlei.org/index.htm?a=aaa&b=bbb&c=ccc"; var intPos = strHref.indexOf("?"); var strRight = strHref.substr(intPos + 1); var arrTmp = strRight.split("&"); for(var i = 0; i < arrTmp.length; i++) { var arrTemp = arrTmp[i].split("="); if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1]; } return ""; } alert(Request("a")); alert(Request("b")); alert(Request("c")); //--> </script>

29、计算停留的时间

<html> <form> <td vAlign="top">您在此停留了: <input size="8" value="在线时间"></td> </form> <script language="JavaScript"> var id, iM = 0, iS = 1; start = new Date(); function go(){ now = new Date(); time = (now.getTime() - start.getTime()) / 1000; time = Math.floor( time); iS = time % 60; iM = Math.floor( time / 60); if ( iS < 10) document.myform.clock.value = " " + iM + " 分 0" + iS + " 秒"; else document.myform.clock.value = " " + iM + " 分 " + iS + " 秒"; id = setTimeout( "go()", 1000); } go(); </script> </body> </html>

30、div为空,只有背景时,背景自动增高

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgzxss.html