[分享]代码大集合——建站必学---不断添加中 ----- 定时跳转到其他页面 ----- <meta http-equiv="refresh" content="20;url=www.tf168.com"> ----- 将本页加入收藏夹脚本 ----- <script language="JavaScript"> function bookmarkit(){window.external.addFavorite(''http://www.tf168.com/perweb'',''天风自助家园'')}//改为你自己的网址和站名 if (document.all)document.write(''<a href="#" onClick="bookmarkit()">将本站加入收藏夹</a>'') </script> ----- 进入网页弹出窗口 ----- <script language="JavaScript"> <!-- <!-- 注意更改文件所在路径--> window.open(''www.sohu.com'','''',''height=200,width=300''); // --> </script> ----- 网页紧贴浏览器 ----- <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> ----- 状态栏跑马灯(摆动式) ----- <script language="Javascript"> <!-- var x = 0 var speed = 120 var text = "古来圣贤皆寂寞,唯有特效留其名!" var course = 120 var text2 = text function Scroll() { window.status = text2.substring(0, text2.length) if (course < text2.length) { setTimeout("Scroll2()", speed) } else { text2 = " " + text2 setTimeout("Scroll()", speed); } } function Scroll2() { window.status = text2.substring(x, text2.length) if (text2.length - x == text.length) { text2 = text x = 0 setTimeout("Scroll()", speed); } else { x++ setTimeout("Scroll2()", speed); } } Scroll() //--> </script> ----- 状态栏跑马灯(射击式) ----- <script language=JavaScript> var MESSAGE="欢迎光临天风网自助家园" var POSITION=100 var DELAY=5 var scroll=new statusMessageObject() function statusMessageObject(p,d){ this.msg =MESSAGE this.out =" " this.pos =POSITION this.delay=DELAY this.i=0 this.reset=clearMessage} function clearMessage(){ this.pos=POSITION} function scroller(){ for (scroll.i=0;scroll.i<scroll.pos;scroll.i++){ scroll.out += " "} if (scroll.pos >= 0) scroll.out += scroll.msg else scroll.out=scroll.msg.substring(-scroll.pos,scroll.msg.length) window.status=scroll.out scroll.out=" " scroll.pos-- if (scroll.pos < -(scroll.msg.length)) { scroll.reset()} setTimeout(''scroller()'',scroll.delay)} function snapIn(jumpSpaces,position){ var msg = scroll.msg var out = "" for(var i=0; i<position; i++) {out+= msg.charAt(i)} for(i=1;i<jumpSpaces;i++) {out += " "} out+=msg.charAt(position) window.status = out if(jumpSpaces <= 1) { position++ if(msg.charAt(position) == '' '') {position++ } jumpSpaces = 100-position }else if (jumpSpaces > 3) {jumpSpaces *= .75} else {jumpSpaces--} if(position != msg.length) { var cmd = "snapIn(" + jumpSpaces + "," + position + ")"; scrollID = window.setTimeout(cmd,scroll.delay); }else{window.status="" jumpSpaces=0 position=0 cmd = "snapIn(" + jumpSpaces + "," + position + ")"; scrollID = window.setTimeout(cmd,scroll.delay); return false } return true} snapIn(100,0); </script> ----- 离开时跳到指定的网址 ----- <body onUnload="leave()"> <script LANGUAGE="JavaScript"> <!-- Begin function leave() { window.open(''http://www.tf168.com'','''',''toolbar=no,menubar=no,location=no,height=70,width=650''); } // End --> </script> ----- 检测访问者的操作系统 ----- <SCRIPT> agent = navigator.userAgent; if (agent.lastIndexOf("Win95")) { document.write('' Windows 95/98/ME''); } else if (agent.lastIndexOf("Win16")) { document.write('' Windows 3.2''); } else if (agent.lastIndexOf("Mac")) { document.write('' Macintosh''); } else if (agent.lastIndexOf("Unix")) { document.write('' Unix''); } else if (agent.lastIndexOf("Linux")) { document.write('' Linux''); } </script> ----- 进入页面弹出欢迎信息框 ----- <body onLoad= alert("您好,欢迎您访问本站!")> ----- 闪烁的表格边框[醒目] ----- <table border="0" width="193" id="myexample" style="border: 5px solid green"> <tr> <td width="175"> <p align="center">天风网自助建站系统</p> </td> </tr> </table> <script language="JavaScript1.2"> <!-- /* Flashing Table Border Script- ?Dynamic Drive (www.dynamicdrive.com) For full source code, installation instructions, 100''s more DHTML scripts, and Terms Of Use, visit dynamicdrive.com */ function flashit(){ if (!document.all) return if (myexample.style.borderColor=="green") myexample.style.borderColor="red" else myexample.style.borderColor="green" } setInterval("flashit()", 500) //--> </script>
|