(推荐)常用JS代码大全

上传人:每**** 文档编号:71007884 上传时间:2022-04-06 格式:DOC 页数:42 大小:73.50KB
收藏 版权申诉 举报 下载
(推荐)常用JS代码大全_第1页
第1页 / 共42页
(推荐)常用JS代码大全_第2页
第2页 / 共42页
(推荐)常用JS代码大全_第3页
第3页 / 共42页
资源描述:

《(推荐)常用JS代码大全》由会员分享,可在线阅读,更多相关《(推荐)常用JS代码大全(42页珍藏版)》请在装配图网上搜索。

1、如果您需要使用本文档,请点击下载按钮下载!常用JS代码大全 一、输入框禁止输入中文<input type=text style=ime-mode:Disabled;>二、最简单的按钮作为链接方法<INPUT TYPE=submit value=ABCnet.CN onclick=location.href=>三、按扭打开Web页对话框<INPUT TYPE=BUTTON NAME=Button VALUE=ABCnet.CN onclick=showModalDialog()>四、改变IE地址栏的IE图标我们要先做一个16*16的icon(图标文件),保存为

2、index.ico。把这个图标文件上传到根目录下并在首页head/head之间加上如下代码:如果您需要使用本文档,请点击下载按钮下载!<link REL = Shortcut Icon href=index.ico><link rel=Bookmark href=favicon.ico> 可以在收藏夹中显示出你的图标五、让网页随意后退<a href=javascript:history.go(-X)>X</a> /把X换成你想要后退在页数/把“-”变成“+”就为前进六、关闭当前窗口<a hre

3、f=/onClick=javascript:window.close();return false;>关闭窗口</a>七、2秒后关闭当前页如果您需要使用本文档,请点击下载按钮下载!<script language=javascript><!-setTimeout(window.close();,2000);-></script>八、2秒后载入指定网页<head><meta http-equiv=refresh content=2;URL=http:/你的网址></head>九、添加到收藏夹<Scri

4、pt Language=javascript>function bookmarkit()window.external.addFavorite(http:/你的网址,你的网站名称)如果您需要使用本文档,请点击下载按钮下载!if (document.all)document.write(<a href=# onClick=bookmarkit()>加入收藏夹</a>)</Script>十、设置该页为首页<a class=chlnk style=cursor:hand HREFonClick=this.style.behavior=url(#defa

5、ult#homepage);this.setHomePage(你的网站名称);>设为首页</a>十一、单击按钮打印出当前页<Script Language=javascript>if (window.print) document.write(<form>+ <input type=button name=print value=打印本页 + onClick=javascript:window.print()></form>);如果您需要使用本文档,请点击下载按钮下载!</Script>十二、最小化、最大化、关闭窗口

6、<object id=hh1 classid=clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11><param name=Command value=Minimize></object><object id=hh2 classid=clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11><param name=Command value=Maximize></object><OBJECT id=hh3 classid=clsid:adb880a6-d8f

7、f-11cf-9377-00aa003b7a11><PARAM NAME=Command VALUE=Close></OBJECT><input type=button value=最小化 onclick=hh1.Click()><input type=button value=最大化 onclick=hh2.Click()>如果您需要使用本文档,请点击下载按钮下载!<input type=button value=关闭 onclick=hh3.Click()>本例适用于IE十三、让弹出窗口总是在最上面:<body onb

8、lur=this.focus();>不要滚动条?让竖条没有:<body style=overflow:scroll;overflow-y:hidden></body>让横条没有:<body style=overflow:scroll;overflow-x:hidden></body>两个都去掉?更简单了<body scroll=no></body>十四、电子邮件处理提交表单<form name=form1 method=post action=mailto:*.com enctype=text/plain>

9、;如果您需要使用本文档,请点击下载按钮下载!<input type=submit></form>十五、在打开的子窗口刷新父窗口的代码里如何写?window.opener.location.reload()十六、如何设定打开页面的大小<body onload=top.resizeTo(300,200);>十七、环境变量本机ip<%=request.servervariables(remote_addr)%>服务器名<%=Request.ServerVariables(SERVER_NAME)%>服务器IP<%=Request.Se

10、rverVariables(LOCAL_ADDR)%>服务器端口<%=Request.ServerVariables(SERVER_PORT)%>服务器时间<%=now%>如果您需要使用本文档,请点击下载按钮下载!IIS版本<%=Request.ServerVariablesSERVER_SOFTWARE)%>脚本超时时间<%=Server.ScriptTimeout%>本文件路径<%=server.mappath(Request.ServerVariables(SCRIPT_NAME)%>服务器CPU数量<%=Reque

11、st.ServerVariables(NUMBER_OF_PROCESSORS)%>服务器解译引擎<%=ScriptEngine & /& ScriptEngineMajorVersion &.&ScriptEngineMinorVersion&.& ScriptEngineBuildVersion %>服务器操作系统<%=Request.ServerVariables(OS)%>本篇文章来源于 黑客基地-全球最大的中文黑客站 原文链接: 1、后退 前进 如果您需要使用本文档,请点击下载按钮下载!<input

12、type=button value=后退 onClick=history.go(-1)> <input type=button value=前进 onClick=history.go( 1 );return true;> 2、返回 <form><input type=button value=返回上一步 onClick=history.back(-1)></form> 3、查看源码 <input type=button name=view value=查看源码 onClick=window.location=view-source:

13、+window.location.href> 4、禁止查看源码 <body oncontextmenu=return false></body> 5、刷新按钮一 <input type=button value=刷新按钮一 onClick=ReloadButton()> <script>function ReloadButton()location.href=i001.htm;</script> 如果您需要使用本文档,请点击下载按钮下载! 刷新按钮二 <input type=button value=刷新按钮二 onCli

14、ck=history.go(0)> 6、回首页按钮 <input type=button value=首页 onClick=HomeButton()> <script>function HomeButton()location.href=;</script> 7、弹出警告框 <input type=button value=弹出警告框 onClick=AlertButton()> <script>function AlertButton()window.alert(要多多光临呀!);</script> 8、状态栏信息

15、 <input type=button value=状态栏信息 onClick=StatusButton()> 如果您需要使用本文档,请点击下载按钮下载!<script>function StatusButton()window.status=要多多光临呀!;</script> 9、背景色变换 <form><input type=button value=背景色变换 onClick=BgButton()></form> <script>function BgButton() if (document.bgCol

16、or=#00ffff) document.bgColor=#ffffff; elsedocument.bgColor=#00ffff; </script> 10、打开新窗口 <input type=button value=打开新窗口 onClick=NewWindow()> <script>function NewWindow()window.open(c01.htm,height=240,width=340,status=no,location=no,toolbar=no,directories=no,menubar=no); 如果您需要使用本文档,请点

17、击下载按钮下载!</script> 11、窗口最小化 <OBJECT id=min type=application/x-oleobject classid=clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11><PARAM name=Command value=Minimize></OBJECT><button onClick=min.Click()>窗口最小化</button> 12、全屏代码 <input type=BUTTON name=FullScreen value=全屏显

18、示 onClick=window.open(document.location, butong_net, fullscreen)> 13、关闭窗口 <OBJECT id=closes type=application/x-oleobject classid=clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11><param name=Command value=Close></object><input type=button value=关闭窗口 onClick=closes.Click();> 如果您需要

19、使用本文档,请点击下载按钮下载!关闭窗口 <input type=button value=关闭窗口 onClick=javascript:self.close()> 14、最大化 <object id=big classid=clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11> <param name=Command value=Maximize></object><input type=button value=最大化 onClick=big.Click()> 15、关闭输入法 <input

20、 style=ime-mode:disabled value=关闭输入法> 16、链接按钮1<input type=button value=链接按钮1 onClick=window.open( Sample, toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width=790,height=520,left=0,top=0) name=input> 如果您需要使用本文档,请点击下载按钮下载! 链接按钮2 <inp

21、ut type=BUTTON NAME=Button value=链接按钮2 onClick=showModalDialog( 链接按钮3 <input type=submit value=链接按钮3 onClick=location.href= 17、警告框显示源代码 <BUTTON onClick=alert(document.documentElement.outerHTML) style=width:110>警告框显示源代码</BUTTON> 18、点击后按钮清空 <input type=button value=打印 onClick=this.st

22、yle.visibility=hidden;window.print();> 如果您需要使用本文档,请点击下载按钮下载! 19、打印 <input type=button value=打印 onClick=window.print();> 20、打印预览 <OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=wb name=wb width=0></OBJECT> <input type=button value=打印预览 onclick=wb.execwb(

23、7,1)> 21、另存为 <input onClick=document.execCommand(saveas,true,常用代码.htm) type=button value=另存为> 22、点击自动复制 <script>function oCopy(obj)obj.select();js=obj.createTextRange();js.execCommand(Copy)</script> <input type=text value=点击自动复制 onClick=oCopy(this) size=11> 如果您需要使用本文档,请点击下

24、载按钮下载! 23、自动选中 <input value=自动选中 onFocus=this.select() onMouseOver=this.focus() size=11> 24、打开源代码 <BUTTON onClick=document.location = view-source: + document.location size=7>打开源代码</BUTTON> 25、新窗口延迟打开 <input type=button value=新窗口延迟打开 onClick=javascript:setTimeout(window.open( 26、

25、实现选中文本框里的前一半的内容 <input type=text value=选中文本框里的前一半的内容 size=30 onmouseover=this.select();tR=document.selection.createRange();tR.moveEnd(character,-8);tR.select();> 如果您需要使用本文档,请点击下载按钮下载!<input type=text value=选中部分内容,非IE可以用这个 size=30 onmouseover=this.selectionStart=this.value.length-4;this.sele

26、ctionEnd=this.value.length> 27、点击清空文字 <input type=text name=artist size=14 value=点击清空文字 onmouseover=this.focus() onfocus=this.select() onclick=if(this.value=点击清空文字)this.value=> 点击清空文字 <input name=name size=11 value=点击清空文字 onMouseOver=this.focus() onblur=if (this.value =) this.value=点击清空文

27、字 onFocus=this.select() onClick=if (this.value=点击清空文字) this.value=> 28、等于标题(title): <input type=text value= id=aa size=20> <script>document.getElementById(aa).value=document.title;</script> 如果您需要使用本文档,请点击下载按钮下载! 29、检测IE是否脱机 <input type=button value=测试 onclick=alert(window.nav

28、igator.onLine)> 30、11种刷新按钮的方法 <input type=button value=刷新 onClick=history.go(0)> <input type=button value=刷新 onClick=location.reload()> <input type=button value=刷新 onClick=location=location> <input type=button value=刷新 onClick=location.assign(location)> <input type=butt

29、on value=刷新 onClick=document.execCommand(Refresh)> <input type=button value=刷新 onClick=window.navigate(location)> <input type=button value=刷新 onClick=location.replace(location)> <input type=button value=刷新 onClick=window.open(自身的文件,_self)> 如果您需要使用本文档,请点击下载按钮下载!<input type=but

30、ton value=刷新 onClick=document.all.WebBrowser.ExecWB(22,1)> <OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT> <form action=自身的文件><input type=submit value=刷新></form> <a id=a1 href=自身的文件></a><input type=bu

31、tton value=刷新 onClick=a1.click()> 31、 <a href=# onClick=document.execCommand(open)>打开</a>32、<a onclick=window.open(i001.htm,height=300,width=300,resizable=no,location=net); href=>打开指定大小网页</a>如果您需要使用本文档,请点击下载按钮下载!33、<a href=# onClick=location.replace(view-source:+locatio

32、n)>使用 记事本 编辑</a> 34、<a href=# onClick=document.execCommand(saveAs)>另存为</a> 35、<a href=# onClick=document.execCommand(print)>打印</a> <a href=javascript:window.print();>打印</a> 36、<a href=mailto:429752806>发送E-mail</a> 37、<a href=# o如果您需要使用本文档,请

33、点击下载按钮下载!nClick=document.execCommand(selectAll)>全选</a> 38、<a href=# onClick=location.reload()>刷新1</a> 39、<a href=# onClick=history.go(0)>刷新2</a> 40、<a href=# onClick=location.replace(view-source:+location)>查看源文件</a> 41、<a href=# onClick=window.open(doc

34、ument.location,url,fullscreen)>全屏显示</a> 42、<a href=# onClick=window.external.showBrowserUI(PrivacySettings,null)>internet选项</a> 如果您需要使用本文档,请点击下载按钮下载! 43、<a href=# oncontextmenu=window.open(this.href);return false;>单击右键将在新窗口中打开</a> 44、<a href=# onClick=history.go(1

35、)>前进1</a> <a href=# onClick=history.forward()>前进2</a> <a href=# onClick=history.go(-1)>后退1</a> <a href=# onClick=history.back()>后退2</a> 45、如果您需要使用本文档,请点击下载按钮下载!<a href=# onClick=window.external.showBrowserUI(OrganizeFavorites,null)>整理收藏夹</a> &

36、lt;SPAN onClick=window.external.addFavorite( style=CURSOR: hand title=网页特效站点>加入收藏</SPAN><a href=# onClick=window.external.addFavorite( <a href=javascript:window.external.AddFavorite( 网页特效站点)>点击加入收藏夹</a> <a href=# onmouseover=window.external.addFavorite( target=_self >鼠标

37、感应收藏本站</a> 如果您需要使用本文档,请点击下载按钮下载! <a href=# onmouseover=this.style.behavior=url(#default#homepage);this.setHomePage( target=_self>鼠标感应设为首页</a> 46、<a href=javascript:window.close()>关闭窗口</a> <a href=# onClick=window.close();return false)>关闭窗口</a> <a href=# o

38、nClick=setTimeout(window.close(),3000)>3秒关闭本窗口</a> <script> function shutwin() window.close(); 如果您需要使用本文档,请点击下载按钮下载!return; </script> <a href=javascript:shutwin();>关闭本窗口</a> 47、<SPAN onClick=var strHref=window.location.href;this.style.behavior=url(#default#homepag

39、e);this.setHomePage( style=CURSOR: hand>设为首页</SPAN> 48、等于标题栏:<script>document.write(document.title);</script> 49、<a href=javascript:void(0); onClick=window.external.AddFavorite(location.href, document.title);>收藏本页</a> <a href=javascript:window.external.AddFavorite

40、(document.location.href, document.title)>收藏本页</a> 如果您需要使用本文档,请点击下载按钮下载! <a href=javascript:window.external.addChannel(typhoon.cdf)>加入频道</a> 50、<a href=i003.htm onclick=return false; ondblclick=window.open(i003.htm);>双击打开链接</a> 51、<style>#close a:hover backgroun

41、d:url(javascript:window.opener=0;window.close();</style><div id=close><a href=>关闭窗口</a></div> 52、<A HREF=javascript:void(0) onMouseover=alert(对不起,禁止选中!)>链接禁止</A> 53、滚动条在左侧,将<html>改为<HTML DIR=RTL> 如果您需要使用本文档,请点击下载按钮下载!54、网页半透明 <body style=filte

42、r:Alpha(Opacity=50)> 55、随机选择背景色 <body> <script> document.body.style.background=(red,blue,pink,navy,gray,yellow,green,purple)parseInt(Math.random()*8); </script> 56、框架页中不显示滚动条: <SCRIPT> self.moveTo(0,0) self.resizeTo(screen.availWidth,screen.availHeight) </SCRIPT> 57、

43、防止网页被框架 <SCRIPT LANGUAGE=JAVASCRIPT> if (top.location != self.location) top.location=self.location; 如果您需要使用本文档,请点击下载按钮下载! </SCRIPT> 58、永远都会带着框架 <script language=javascript><!- if (window = top)top.location.href = frame.htm; /frame.htm为框架网页 / -></script> 59、窗口自动最大化 <s

44、cript language=JavaScript><!- self.moveTo(0,0) self.resizeTo(screen.availWidth,screen.availHeight) /-></script> 60、打开窗口自动最大化 <OBJECT classid=clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11 onreadystatechange=if (this.readyState=4) this.Click(); VIEWASTEXT><PARAM name=Command value

45、=Maximize></OBJECT> 如果您需要使用本文档,请点击下载按钮下载!  61、爽眼闪屏代码<script>var color = new Array;color1 = black;color2 = white;for(x = 0; x <3; x+)document.bgColor = colorx;if(x = 2)x = 0;</script> 62、不能被另存为 <noscript><iframe src=*.html></iframe></noscript> 63、汉

46、字字库调用 <script> for(i=19968;i<40870;i+)document.write(String.fromCharCode(i); </script> 64、显示现在时间的脚本 如果您需要使用本文档,请点击下载按钮下载!<script language=vbscript>document.write now</script> 65、显示最后修改时间的脚本 <script>document.write(document.lastModified)</script> 66、按下F12键,直接返回首页

47、 <script>function look() if(event.keyCode=123)document.location.href= if(document.onkeydown=null) document.onkeydown=look </script> 67、端口检测<img src=http:/www.winliuxq/zza.jpg onload=alert(端口可用) onerror=alert(端口禁止).> 68、无法最小化的窗口 如果您需要使用本文档,请点击下载按钮下载!<body onblur=self.focus();>

48、 69、链接点外部css文件 <style>import url(ie.css);</style> 70、内嵌式框架-网页中调用另外网页: <object type=text/x-scriptlet width=600 height=1000 data= 71、刷新改变窗口大小 <OBJECT classid=clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11 onreadystatechange=if (this.readyState=4) this.Click(); VIEWASTEXT><PARAM nam

49、e=Command value=Maximize></OBJECT> 72、JavaScript实现网页竖虚线 <script>hei=120;d1=2;d2=2;cou=Math.floor(hei/(d1+d2); document.write(<table cellspacing=0 cellpadding=0 width=1 height=+hei+>); 如果您需要使用本文档,请点击下载按钮下载!for(i=0;i<cou;i+)document.write(<tr><td height=+d2+><tr><td height=+d1+ bgcolor=333333>)</script></table> 73、js翻页 <script>document.write(<a href=+location.href.replace(/.html/g,_2.html)+>2</a>);</script> (注:可编辑下载,若有不当之处,请指正,谢谢!)

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!