编辑主页 > 列表 > 正文
JS特效代码
作者:mana 发布时间:2018/06/21 11:35:46 分数:0 跟帖:1
1、禁止页面正文选取 <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()"> 防止点击空链接时,页面往往重置到页首端。 代码“javascript:void(null)”代替原来的“#”标记 如何避免别人把你的网页放在框架中 <script language=“javascript”><!--if (self!=top){top.location=self.location;} -->< /script> 2、页面定时刷新 <meta http-equiv="refresh" content="秒" > 3、页面定时转向新的地址 <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> 4、设为首页代码 <a href=# onclick="this.style.behavior='url(#default#homepage)';this.sethomepage('url');">设为首页</a> 


网友跟帖 共1 条 [我也要发表回复]
删除回复mana - 回复于2018/6/21 11:38:58
1
5、添加收藏代码 <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 

      ·常用网页JS特效代码>>
版区推荐 >>
广告区