1。忽视右键 <body oncontextmenu="return false"> 或 <body style="overflow-y:hidden"> 2。加入背景音乐 IE:<bgsound src="*.mid" loop=infinite> NS:<embed src="*.mid" autostart=true hidden=true loop=true> </embed> *.mid你的背景音乐的midi格式文件 3。简单的window.open方法 <a href="#" onclick="javascript:window.open(文件路径/文件名,newwindow, toolbar=no,scrollbars=yes,resizable=no,top=0,left=0, width=400,height=300);">文字或图片</a> 参数解释: <script LANGUAGE="javascript"> js脚本开始; window.open 弹出新窗口的命令; 文件路径/文件名 弹出窗口的文件名; newwindow 弹出窗口的名字(不是文件名),非必须,可用空代替; width=400 窗口宽度; height=300 窗口高度; top=0 窗口距离屏幕上方的象素值; left=0 窗口距离屏幕左侧的象素值; toolbar=no 是否显示工具栏,yes为显示; menubar,scrollbars 表示菜单栏和滚动栏。 resizable=no 是否允许改变窗口大小,yes为允许; location=no 是否显示地址栏,yes为允许; status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许; </SCRIPT> js脚本结束 4。简单的页面加密 <script LANGUAGE="javascript"> <!-- function loopy(){ var sWord =""; while(sWord!="login"){sWord=prompt("请输入你的登陆密码");} alert("登陆成功!"); } loopy() //--> </script> 5。拉动页面时背景图不动 <style> body{background-image:url(logo.gif); background-repeat:no-repeat;background-position:center} </style> 6。让浏览器在保存页面时保存失败 <NOSCRIPT><iframe src="*.html"></iframe></NOSCRIPT> 7。随机替换图片 <script> document.write(<img src="img/+parseInt(Math.random()*(5)) +.gif"height="40" width="50">) </script> 图片文件名为0.gif 1.gif 2.gif 3.gif 4.gif 8。窗口定时关闭 先将如下代码网页文件的区: <script language="javascript"> function closeit() { setTimeout("self.close()",10000) //毫秒 } </script> 然后再在<body>标内加入如:<body onload="closeit()"> 9。网页自动关闭 <html> <head> <object id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> <param name="Command" value="Close"> </object> </head> <body onload="window.setTimeout(closes.Click(),10000)"> 这个窗口会在10秒过后自动关闭,而且不会出现提示. </body> </html> 10。网页自动刷新 在head部记入 <META HTTP-EQUIV="Refresh" content="20"> 其中20为20秒后自动刷新,你可以更改为任意值。 11。网页自动转页 <META HTTP-EQUIV="Refresh" CONTENT="时间(秒);URL=地址"> 12。保持layer在最前面,而不被Iframe、Object所覆盖 在Layer中再插Iframe 或 Object 设z-Index值 <div z-Index:2><object xxx></object> # 前面 <div z-Index:1><object xxx></object> # 后面 <div id="Layer2" style="position:absolute; top:40;width:400px; height:95px;z-index:2"> height=100% width=100%> <iframe width=0 height=0></iframe> </div> <div id="Layer1" style="position:absolute; top:50;width:200px; height:115px;z-index:1"> <iframe height=100% width=100%></iframe> </div> 13。返回上一页 <a href=javascript:history.back(1)>『返回上一页』</a> 14。关闭窗口 <a href=javascript:self.close()>『关闭窗口』</a> 15。关于iframe的透明背景 <IFRAME ID="iFrame1" SRC="iframe.htm" allowTransparency="true" style="background-color: green"></IFRAME> ******************************************************************************* ('window.html','','width=394,height=290')弹出窗口 禁止页面正文选取 <body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false"onmouseup="document.selection.empty()"> 消除ie6自动出现的图像工具栏,设置 GALLERYIMG属性为false或no . <IMG SRC="mypicture.jpg" HEIGHT="100px" WIDTH="100px" GALLERYIMG="no"> 防止点击空链接时,页面往往重置到页首端。 代码“javascript:void(null)”代替原来的“#”标记 如何避免别人把你的网页放在框架中 <script language=“javascript”><!--if (self!=top){top.location=self.location;} -->< /script> 页面定时刷新 <meta http-equiv="Refresh" content="秒" > 页面定时转向新的地址 <meta http-equiv="refresh" content="秒;URL=url"> 显示日期 <script language="javascript"><!-- today=new Date(); var week; var date; if(today.getDay()==0) week="星期日" if(today.getDay()==1) week="星期一" if(today.getDay()==2) week="星期二" if(today.getDay()==3) week="星期三" if(today.getDay()==4) week="星期四" if(today.getDay()==5) week="星期五" if(today.getDay()==6) week="星期六" date=(today.getYear())+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日"+" " document.write("<span style='font-size: 9pt;'>"+date+week+"</span>"); // --> </script> 设为首页 <A href=# onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('url');">设为首页</A> 添加收藏 <A href="javascript:window.external.AddFavorite('url','title')"> 加入收藏夹</A> 你谢我阿?难得哦~~我也有关闭窗口,这个是不会弹出提示直接关的: 把如下代码加入<body>区域中 <OBJECT id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> <param name="Command" value="Close"> </object> <script language="javascript">function shutwin(){closes.Click();return;}</script> <a href="javascript:shutwin();">关闭本窗口</a> 随机图片: 把如下代码加入<body>区域中 <script language="javascript"><!-- today=new Date(); jran=today.getTime(); function rnd() { ia=9301; ic=49297; im=233280; jran = (jran*ia+ic) % im; return jran/(im*1.0); }; function rand(number) { return Math.ceil(rnd()*number); }; document.write("<CENTER>"); for(i=1;i<=1;i++) { myNum=(rand(10)); //改成你要随机显示的图片数; if(myNum == 1) document.write("<img src='photo/back.jpg'>"); if(myNum == 2) document.write("<img src='photo/j2.gif'>"); //图片路径,可用http:// ; if(myNum == 3) document.write("<img src='photo/email.gif'>"); if(myNum == 4) document.write("<img src='photo/arrow.gif'>"); if(myNum == 5) document.write("<img src='photo/j2.gif'>"); if(myNum == 6) document.write("<img src='photo/email.gif'>"); if(myNum == 7) document.write("<img src='photo/arrow.gif'>"); if(myNum == 8) document.write("<img src='photo/j2.gif'>"); if(myNum == 9) document.write("<img src='photo/back.jpg'>"); if(myNum == 10) document.write("<img src='photo/email.gif'>"); else { document.write(); } }; document.write("</CENTER>"); //--> </script> 其实改一改随机什么都行,也不一定在body中 图片显隐效果 脚本说明: 把如下代码加入<body>区域中 <script language=javascript> // Flash Image Extension for Dreamwever ,by Yichun Yuan(dezone@sina.com) nereidFadeObjects = new Object(); nereidFadeTimers = new Object(); function nereidFade(object, destOp, rate, delta){ if (!document.all) return if (object != "[object]"){ //do this so I can take a string too setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0); return; } clearTimeout(nereidFadeTimers[object.sourceIndex]); diff = destOp-object.filters.alpha.opacity; direction = 1; if (object.filters.alpha.opacity > destOp){ direction = -1; } delta=Math.min(direction*diff,delta); object.filters.alpha.opacity+=direction*delta; if (object.filters.alpha.opacity != destOp){ nereidFadeObjects[object.sourceIndex]=object; nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate); } } </script> <a href=#><img src="photoshopcn.jpg" border=0 onMouseOut=nereidFade(this,50,10,5) onMouseOver=nereidFade(this,100,10,5) style="FILTER: alpha(opacity=40)"></a> 在工作中常用到的一些代码,贴出来有需要的就参考一下吧!
回复Comments
作者:
{commentrecontent}