版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、常用 JS 代码大全一、输入框禁止输入中文<input type="text" style="ime-mode:Disabled;">二、最简单的按钮作为链接方法<INPUT TYPE="submit" value="ABCnet.CN"onclick="location.href=''">三、按扭打开 Web 页对话框<INPUT TYPE="BUTTON" NAME="Butt
2、on"VALUE="ABCnet.CN"onclick="showModalDialog('')">四、改变 IE 地址栏的 IE 图标我们要先做一个16*16的icon (图标文件),保存为index.ico。把这个图标文件上传到根目录下并在首页vhead>v /head>之间加上如下代码:<link REL = "Shortcut Icon" href="index.ico"><link rel="Bookm
3、ark" href="favicon.ico"> 可以在 收藏夹中显示出你的图标五、让网页随意后退<a href="javascript:history.go(-X)">X</a> /把X 换成你想要后退在页数/把“-” 变成 “+” 就为前进六、关闭当前窗口<a href="/"onClick="javascript:window.close();re
4、turn false;"> 关闭窗口 </a>七、2 秒后关闭当前页<script language="javascript"><!- setTimeout('window.close();',2000);-></script>八、2 秒后载入指定网页<head><meta http-equiv="refresh" content="2;URL=http
5、:/ 你 的网址 "></head>九、添加到收藏夹<Script Language="javascript">function bookmarkit()window.external.addFavorite('http:/ 你的网址 ','你的网站 名称 ')if (document.all)document.write('<a href="#" onClick="bookmarkit()"&
6、gt; 加入收藏夹 </a>')</Script>十、设置该页为首页<a class="chlnk" style="cursor:hand" HREF onClick="this.style.behavior='url(#default#homepage)'this.setHomePage(你的网站名称);">设为首页 </a>十一、单击按钮打印出当前页<Script Language=
7、"javascript">if (window.print) document.write('<form>'+ '<input type=button name=print value=" 打印本页 "+'onClick="javascript:window.print()"></form>');</Script>十二、最小化、最大化、关闭窗口<object
8、 id=hh1classid="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&q
9、uot; value="Maximize"></object><OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><PARAM NAME="Command" VALUE="Close"></OBJECT><input type=button value= 最小化 onclick=hh1.Clic
10、k()><input type=button value= 最大化 onclick=hh2.Click()><input type=button value= 关闭 onclick=hh3.Click()>本例适用于 IE十三、让弹出窗口总是在最上面 :<body onblur="this.focus();">不要滚动条 ?让竖条没有 :<body style='overflow:scroll;overflow-y:hidden'>&
11、amp;lt;/body>让横条没有 :<body style='overflow:scroll;overflow-x:hidden'></body>两个都去掉?更简单了<body scroll="no"></body>十四、电子邮件处理提交表单<form name="form1" method="post"action="mailto:*.com" encty
12、pe="text/plain"><input type=submit></form>十五、在打开的子窗口刷新父窗口的代码里如何写?window.opener.location.reload()十六、如何设定打开页面的大小<body onload="top.resizeTo(300,200);">十七、环境变量本机ip<%=request.servervariables("remote_addr")%> 服务器名
13、<%=Request.ServerVariables("SERVER_NAME")%> 服务器IP<%=Request.ServerVariables("LOCAL_ADDR")%> 服务器端口<%=Request.ServerVariables("SERVER_PORT")%> 服务器时间 <%=now%>IIS 版本<%=Request.ServerVariables"SERVER_SOFTWAR
14、E")%>脚本超时时间 <%=Server.ScriptTimeout%> 本文件路径<%=server.mappath(Request.ServerVariables("SCRIPT_NA ME")%>服务器 CPU 数量<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%>服务器解译引擎 <%=ScriptEngine & "/"&
15、 ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %>服务器操作系统<%=Request.ServerVariables("OS")%> 本篇文章来源于 黑客基地 -全球最大的中文黑客站 原文链 接: 1、后退 前进<input type="button" value=&quo
16、t; 后退 " onClick="history.go(-1)"><input type="button" value=" 前进 " onClick="history.go( 1 );return true;">2、返回<form><input type="button" value=" 返回上一步 " onClick="history.back(-1)"&
17、;gt;</form>3、查看源码<input type="button" name="view" value=" 查看源码 " onClick="window.location="view-source:"+window.location.href">4、禁止查看源码<body oncontextmenu="return false"></body>5、刷新按钮一
18、<input type="button" value=" 刷新按钮一 " onClick="ReloadButton()"><script>functionReloadButton()location.href="i001.htm"</script>刷新按钮二<input type="button" value=" 刷新按钮二 " onClick="history.go
19、(0)">6、回首页按钮<input type="button" value=" 首页 " onClick="HomeButton()"><script>functionHomeButton()location.href=;</script>7、弹出警告框<input type="button" value=" 弹出警告框 " onClick="AlertButto
20、n()"><script>function AlertButton()window.alert(" 要多多光 临呀! ");</script>8、状态栏信息<input type="button" value=" 状态栏信息 " onClick="StatusButton()"><script>function StatusButton()window.status="
21、要多多 光临呀! "</script>9、背景色变换<form><input type="button" value=" 背景色变换 " onClick="BgButton()"></form><script>function BgButton()if (document.bgColor='#00ffff')document.bgColor='#ffffff
22、9; elsedocument.bgColor='#00ffff' </script>10、打开新窗口<input type="button" value=" 打开新窗口 " onClick="NewWindow()"><script>function NewWindow()window.open("c01.htm","","height=240,width= 340,status=no
23、,location=no,toolbar=no,directories=no,menubar= no");</script>11、窗口最小化<OBJECT id="min" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">< ;PARAM name="Command" value="Minimize"
24、></OBJECT><button onClick="min.Click()"> 窗口最小化 </button>12、全屏代码<input type="BUTTON" name="FullScreen" value=" 全屏显 示 " onClick="window.open(document.location, 'butong_net', 'fullscreen'
25、;)">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=&qu
26、ot; 关闭窗口 " onClick="closes.Click();">关闭窗口<input type=button value= 关闭窗口 onClick="javascript:self.close()">14、最大化<object id=big classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11" ><param name="Command" value=&quo
27、t;Maximize"></object><input type=button value= 最大化 onClick=big.Click()>15、关闭输入法<input style="ime-mode:disabled" value= 关闭输入法 >16、链接按钮 1<input type="button" value=" 链接按钮 1" onClick="window.open(' '
28、Sample', 'toolbar=no,location=no,directories=no,status=no,menubar=no,s crollbars=no,resizable=yes,copyhistory=yes,width=790,height= 520,left=0,top=0')" name="input">链接按钮 2<input type="BUTTON" NAME="Button" value=" 链接按钮 2" onClick
29、="showModalDialog(' 链接按钮 3<input type="submit" value=" 链接按钮 3" onClick="location.href='17、警告框显示源代码<BUTTON onClick=alert(document.documentElement.outerHTML) style="width:110"> 警告框显示源代码 </BUTTON>18、点击后按钮清空<input
30、type=button value=' 打印 ' onClick="this.style.visibility='hidden'window.print();">19、打印<input type=button value=' 打印 ' onClick="window.print();">20、打印预览<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height
31、=0 id=wb name=wb width=0></OBJECT> <input type=button value= 打印预览 onclick="wb.execwb(7,1)">21、另存为<input onClick="document.execCommand('saveas','true',' 常 用代码 .htm')" type=button value= 另存为 >22、点击自动复制<
32、script>function oCopy(obj)obj.select();js=obj.createTextRange();js.execComm and("Copy")</script><input type="text" value=" 点击自动复制 "onClick="oCopy(this)" size="11">23、自动选中<input value=" 自动选中 " onFocu
33、s="this.select()"onMouseOver="this.focus()" size="11">24、打开源代码<BUTTON onClick="document.location = 'view-source:' +document.location" size="7"> 打开源代码</BUTTON>25、新窗口延迟打开<input type=button value= 新窗口延迟打
34、开 onClick=javascript:setTimeout("window.open('26、实现选中文本框里的前一半的内容<input type="text" value=" 选中文本框里的前一半的内容 " size=30 onmouseover="this.select();tR=document.selection.createRange ();tR.moveEnd('character',-8);tR.select();"><input type=
35、"text" value=" 选中部分内容, 非 IE 可以用这个 " size=30 onmouseover="this.selectionStart=this.value.length-4;this.select ionEnd=this.value.length">27、点击清空文字<input type="text" name="artist" size=14 value=" 点击清空 文字 " onmouseover=this.focus(
36、) onfocus=this.select() onclick="if(this.value=' 点击清空文字 ')this.value=''">点击清空文字<input name=name size=11 value= 点击清空文字 onMouseOver=this.focus() onblur="if (this.value ='') this.value=' 点击清空文字 '" onFocus=this.select() onClick="if (
37、this.value=' 点击清空文字 ') this.value=''">28、等于标题 (title):<input type="text" value="" id="aa" size="20"><script>document.getElementById("aa").value=document .title;</script>29、检测 IE 是否
38、脱机<input type="button" value=" 测试 " onclick="alert(window.navigator.onLine)">30、11 种刷新按钮的方法<input type=button value= 刷新 onClick="history.go(0)"><input type=button value= 刷新 onClick="location.reload()"><
39、;input type=button value= 刷新 onClick="location=location"><input type=button value= 刷新 onClick="location.assign(location)"><input type=button value= 刷新 onClick="document.execCommand('Refresh')"><input type=button value= 刷
40、新 onClick="window.navigate(location)"><input type=button value= 刷新 onClick="location.replace(location)"><input type=button value= 刷新 onClick="window.open(' 自 身的文件 ','_self')"><input type=button value= 刷新 onClick=
41、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 h
42、ref=" 自身的文件 "></a><inputtype=button value= 刷新 onClick="a1.click()">31、<a href="#" onClick=document.execCommand("open")>打开 </a>32、<a onclick="window.open('i001.htm','',
43、39;height=300,width=300,resiz able=no,location=net');" href=""> 打开指定大小网页 </a>33、<a href="#"onClick=location.replace("view-source:"+location)> 使用 记 事本 编辑 </a>34、<a href="#" onClick=document.execCo
44、mmand("saveAs")> 另存为 </a>35、<a href="#" onClick=document.execCommand("print")>打印 </a><a href="javascript:window.print();"> 打印 </a>36、<a href=mailto:429752806> 发送 E-mail&
45、amp;lt;/a>37、<a href="#" onClick=document.execCommand("selectAll")> 全选 </a>38、<a href="#" onClick=location.reload()> 刷新 1</a>39、<a href="#" onClick=history.go(0)> 刷新 2</a&g
46、t;40、<a href="#"onClick=location.replace("view-source:"+location)> 查看源 文件 </a>41、<a href="#" onClick=window.open(document.location,"url","fullscreen")> 全屏显示 </a>42、<a href="#"on
47、Click=window.external.showBrowserUI("PrivacySettings",nu ll)>internet 选项 </a>43、<a href="#" oncontextmenu="window.open(this.href);return false;"> 单击右键将在新窗口中打开 </a>44、 <a href="#" onClick=history.go(1)&
48、;gt; 前进 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="#&
49、quot; onClick=window.external.showBrowserUI("OrganizeFavorites", null)> 整理收藏夹 </a><SPAN onClick="window.external.addFavorite('http:/www.winliuxq.co m/','网页特效站点')"style="CURSOR: hand" title= 网页特效站 点 > 加入收藏 </SPAN&
50、amp;gt;<a href="#" onClick="window.external.addFavorite('http:/www.winliuxq.co m/','网页特效站点')">添加到收藏夹</A><a href="javascript:window.external.AddFavorite(' ' 网页特效站点 ')"> 点击加入收藏夹 </a>&l
51、t;a href="#" onmouseover="window.external.addFavorite(' >鼠标感应收藏本 站</a ><a href="#" onmouseover="this.style.behavior='url(#default#homepage)'thi s.setHomePage(' target="_self">鼠标感应设为首页 </a>46、&
52、;lt;a href="javascript:window.close()"> 关闭窗口 </a><a href="#" onClick=window.close();return false)> 关闭窗 口& lt;/a ><a href="#" onClick=setTimeout(window.close(),3000)>3 秒关闭本窗口 </a><script&
53、;gt;function shutwin()window.close();return;</script><a href="javascript:shutwin();"> 关闭本窗口 </a>47、<SPAN onClick="var strHref=window.location.href;this.style.behavior='url(#default# homepage)'this.setHomePage(' style="C
54、URSOR: hand"> 设为首页 </SPAN>48、等于标题栏:&l t;script>document.write(document.title);</script>49、<a href="javascript:void(0);" onClick='window.external.AddFavorite(location.href,document.title);'> 收藏本页 </a>&
55、;lt;a href="javascript:window.external.AddFavorite(document.locatio n.href, document.title)"> 收藏本页 </a><a href=javascript:window.external.addChannel("typhoon.cdf")> 加入频道 </a>50、<a href="i003.htm" onclick="retu
56、rn false;" ondblclick="window.open('i003.htm');"> 双击打开链接 </a>51、<style>#close a:hover background:url(javascript:window.opener=0;window.close(); </style><div id=close><a href=""> 关闭窗口 <
57、;/a></div>52、<A HREF="javascript:void(0)" onMouseover="alert(' 对不起 , 禁止选中 !')"> 链接禁止 </A>53、滚动条在左侧,将<html>改为<HTMLDIR="RTL">54、网页半透明<body style="filter:Alpha(Opacity=50)"
58、;>55、随机选择背景色<body><script>document.body.style.background=("red","blue","pink","navy"," gray","yellow","green","purple")parseInt(Math.random()*8);</script>56、框架页中不显示滚动条:&am
59、p;lt;SCRIPT>self.moveTo(0,0) self.resizeTo(screen.availWidth,screen.availHeight)</SCRIPT>57、防止网页被框架<SCRIPT LANGUAGE=JA VASCRIPT>if (top.location != self.location) top.location=self.location;</SCRIPT>58、永远都会带着框架<script language="javascript&
60、quot;><!-if (window = top)top.location.href = "frame.htm" /frame.htm 为框架网页/ -></script>59、窗口自动最大化<script language="JavaScript"><!- self.moveTo(0,0) self.resizeTo(screen.availWidth,screen.availHeight) /-></scrip
61、t>60、打开窗口自动最大化<OBJECT classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" onreadystatechange="if (this.readyState=4) this.Click();" VIEWASTEXT><PARAM name="Command"value="Maximize"></OBJECT> 61、爽眼闪屏代码 <script>var color = new Array;color1 = "bla
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 镀膜工岗中团队激励考核试卷含答案
- 2026年生物安全培训试题及答案
- 拜耳法溶出工岗位规划考核试卷含答案
- 有色金属材热处理工变更管理评优考核试卷含答案
- 植物原料水解工风险评估知识考核试卷含答案
- 水工混凝土维修工岗中技能测试考核试卷含答案
- 建筑幕墙设计师安全文化水平考核试卷含答案
- 盐斤分装设备操作工安全专项能力考核试卷含答案
- 2026年造价工程师《工程造价管理》培训试卷(附解析)
- 2026年人力资源开发公司招聘考试笔试试题(含答案)
- 2025广东惠州市博罗县自然资源局招聘编外人员76人考试笔试备考题库及答案解析
- 办公室文秘工作日常管理方案
- 化学实验指导教材编写规定
- 旅游安全培训风险课件
- CN120192646A 一种pha纳米水性悬浮液及其制备方法与应用
- DB13T 5406-2021 耕地地力主要指标分级诊断
- 景区合作商家管理制度
- JG/T 191-2006城市社区体育设施技术要求
- 个人债务转让合同范例
- 《分数除法(二)》(教学设计)-2023-2024学年北师大版五年级数学下册
- 不停电作业推广方案
评论
0/150
提交评论