常用的"收藏,打印,另存为"等JS代码(按纽INPUT和链接形式)

 
  1. 脚本说明:   
  2. 把如下代码加入<body>区域中:   
  3. 后退 前进   
  4. <input type="button" value="后退" onClick="history.go(-1)">   
  5. <input type="button" value="前进" onClick="history.go( 1 );return true;">   
  6.   
  7. 返回   
  8. <form><input type="button" value="返回上一步" onClick="history.back(-1)"></form>   
  9.   
  10. 查看源码   
  11. <input type="button" name="view" value="查看源码" onClick="window.location="view-source:" +window.location.href">   
  12.   
  13. 禁止查看源码   
  14. <body οncοntextmenu="return false"></body>   
  15.   
  16. 刷新按钮一   
  17. <input type="button" value="刷新按钮一" onClick="ReloadButton()">   
  18. <script>function ReloadButton(){location.href="i001.htm";}</script>   
  19.   
  20. 刷新按钮二   
  21. <input type="button" value="刷新按钮二" onClick="history.go(0)">   
  22.   
  23. 回首页按钮   
  24. <input type="button" value="首页" onClick="HomeButton()">   
  25. <script>function HomeButton(){location.href=http://www.winliuxq.com;}</script>   
  26.   
  27. 弹出警告框   
  28. <input type="button" value="弹出警告框" onClick="AlertButton()">   
  29. <script>function AlertButton(){window.alert("要多多光临呀!");}</script>   
  30.   
  31. 状态栏信息   
  32. <input type="button" value="状态栏信息" onClick="StatusButton()">   
  33. <script>function StatusButton(){window.status="要多多光临呀!";}</script>   
  34.   
  35. 背景色变换   
  36. <form><input type="button" value="背景色变换" onClick="BgButton()"></form>   
  37. <script>function BgButton(){   
  38. if (document.bgColor=='#00ffff')   
  39.     {document.bgColor='#ffffff';}   
  40. else{document.bgColor='#00ffff';}   
  41. }   
  42. </script>   
  43.   
  44. 打开新窗口   
  45. <input type="button" value="打开新窗口" onClick="NewWindow()">   
  46. <script>function NewWindow(){window.open("c01.htm","","height=240,width=340,status=no,location=no,toolbar=no,directories=no,menubar=no");}   
  47. </script>   
  48.   
  49. 窗口最小化   
  50. <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>   
  51.   
  52. 全屏代码   
  53. <input type="BUTTON" name="FullScreen" value="全屏显示" onClick="window.open(document.location, 'butong_net', 'fullscreen')">   
  54.   
  55. 关闭窗口   
  56. <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();">   
  57.   
  58. 关闭窗口   
  59. <input type=button value=关闭窗口 onClick="javascript:self.close()">    
  60.   
  61. 最大化   
  62. <object id=big classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">    
  63. <param name="Command" value="Maximize"></object><input type=button value=最大化 onClick=big.Click()>   
  64.   
  65. 关闭输入法   
  66. <input style="ime-mode:disabled" value=关闭输入法>   
  67.   
  68. 链接按钮1   
  69. <input type="button" value="链接按钮1" onClick="window.open('http://www.winliuxq.com/', '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">   
  70.   
  71. 链接按钮2   
  72. <input type="BUTTON" NAME="Button" value="链接按钮2" onClick="showModalDialog('http://www.winliuxq.com/')">   
  73.   
  74. 链接按钮3   
  75. <input type="submit" value="链接按钮3" onClick="location.href='http://www.winliuxq.com/'">   
  76.   
  77. 警告框显示源代码   
  78. <BUTTON onClick=alert(document.documentElement.outerHTML) style="width:110">警告框显示源代码</BUTTON>   
  79.   
  80. 点击后按钮清空   
  81. <input type=button value='打印' onClick="this.style.visibility='hidden';window.print();">   
  82.   
  83. 打印   
  84. <input type=button value='打印' onClick="window.print();">   
  85.   
  86. 打印预览   
  87. <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>   
  88. <input type=button value=打印预览 οnclick="wb.execwb(7,1)">   
  89.   
  90. 另存为   
  91. <input onClick="document.execCommand('saveas','true','常用代码.htm')" type=button value=另存为>   
  92.   
  93. 点击自动复制   
  94. <script>function oCopy(obj){obj.select();js=obj.createTextRange();js.execCommand("Copy")}</script>   
  95. <input type="text" value="点击自动复制" onClick="oCopy(this)" size="11">   
  96.   
  97. 自动选中   
  98. <input value="自动选中" onFocus="this.select()" onMouseOver="this.focus()" size="11">   
  99.   
  100. 打开源代码   
  101. <BUTTON onClick="document.location = 'view-source:' + document.location" size="7">打开源代码</BUTTON>   
  102.   
  103. 新窗口延迟打开   
  104. <input type=button value=新窗口延迟打开 onClick=javascript:setTimeout("window.open('http://www.winliuxq.com/')",10000)>   
  105.   
  106. 实现选中文本框里的前一半的内容   
  107. <input type="text" value="选中文本框里的前一半的内容" size=30 οnmοuseοver="this.select();tR=document.selection.createRange();tR.moveEnd('character',-8);tR.select();">   
  108. <input type="text" value="选中部分内容,非IE可以用这个" size=30 οnmοuseοver="this.selectionStart=this.value.length-4;this.selectionEnd=this.value.length">   
  109.      
  110. 点击清空文字   
  111. <input type="text" name="artist" size=14 value="点击清空文字" οnmοuseοver=this.focus() οnfοcus=this.select() οnclick="if(this.value=='点击清空文字')this.value=''">   
  112.   
  113. 点击清空文字   
  114. <input name=name size=11 value=点击清空文字 onMouseOver=this.focus() οnblur="if (this.value =='') this.value='点击清空文字'" onFocus=this.select() onClick="if (this.value=='点击清空文字') this.value=''">   
  115.   
  116. 等于标题(title):   
  117. <input type="text" value="" id="aa" size="20">   
  118. <script>document.getElementById("aa").value=document.title;</script>   
  119.   
  120. 检测IE是否脱机   
  121. <input type="button" value="测试" οnclick="alert(window.navigator.onLine)">   
  122.   
  123. 11种刷新按钮的方法   
  124. <input type=button value=刷新 onClick="history.go(0)">   
  125. <input type=button value=刷新 onClick="location.reload()">   
  126. <input type=button value=刷新 onClick="location=location">   
  127. <input type=button value=刷新 onClick="location.assign(location)">   
  128. <input type=button value=刷新 onClick="document.execCommand('Refresh')">   
  129. <input type=button value=刷新 onClick="window.navigate(location)">   
  130. <input type=button value=刷新 onClick="location.replace(location)">   
  131. <input type=button value=刷新 onClick="window.open('自身的文件','_self')">   
  132. <input type=button value=刷新 onClick=document.all.WebBrowser.ExecWB(22,1)>    
  133. <OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>   
  134. <form action="自身的文件"><input type=submit value=刷新></form>   
  135. <a id=a1 href="自身的文件"></a><input type=button value=刷新 onClick="a1.click()">

  136. =========================================================================================================
  137. 脚本说明:   
  138. 把如下代码加入<body>区域中:   
  139. <a href="#" onClick=document.execCommand("open")>打开</a>  
  140.   
  141. <a onclick="window.open('i001.htm','','height=300,width=300,resizable=no,location=net');" href="">打开指定大小网页</a  
  142.   
  143. <a href="#" onClick=location.replace("view-source:"+location)>使用 记事本 编辑</a>  
  144.   
  145. <a href="#" onClick=document.execCommand("saveAs")>另存为</a>  
  146.   
  147. <a href="#" onClick=document.execCommand("print")>打印</a>  
  148. <a href="javascript:window.print();">打印</a>  
  149.   
  150. <a href=mailto:429752806@163.com>发送E-mail</a>  
  151.   
  152. <a href="#" onClick=document.execCommand("selectAll")>全选</a>  
  153.   
  154. <a href="#" onClick=location.reload()>刷新1</a>  
  155.   
  156. <a href="#" onClick=history.go(0)>刷新2</a>  
  157.   
  158. <a href="#" onClick=location.replace("view-source:"+location)>查看源文件</a>  
  159.   
  160. <a href="#" onClick=window.open(document.location,"url","fullscreen")>全屏显示</a>  
  161.   
  162. <a href="#" onClick=window.external.showBrowserUI("PrivacySettings",null)>internet选项</a>  
  163.   
  164. <a href="#" oncontextmenu="window.open(this.href);return false;">单击右键将在新窗口中打开</a>  
  165.   
  166. <a href="#" onClick=history.go(1)>前进1</a>  
  167.   
  168. <a href="#" onClick=history.forward()>前进2</a>  
  169.   
  170. <a href="#" onClick=history.go(-1)>后退1</a>  
  171.   
  172. <a href="#" onClick=history.back()>后退2</a>  
  173.   
  174. <a href="#" onClick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夹</a>  
  175.   
  176. <SPAN onClick="window.external.addFavorite('http://www.winliuxq.com/','网页特效站点')" style="CURSOR: hand" title=网页特效站点>加入收藏</SPAN>    
  177.   
  178. <a href="#" onClick="window.external.addFavorite('http://www.winliuxq.com/','网页特效站点')">添加到收藏夹</A>  
  179.   
  180. <a href="javascript:window.external.AddFavorite('http://www.winliuxq.com/', '网页特效站点')">点击加入收藏夹</a>  
  181.   
  182. <a href="#" onmouseover="window.external.addFavorite('http://www.winliuxq.com/','网页特效站点')" target="_self" >鼠标感应收藏本站</a>  
  183.   
  184. <a href="#" onmouseover="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.yiloo.com/js/');" target="_self">鼠标感应设为首页</a>    
  185.   
  186. <a href="javascript:window.close()">关闭窗口</a>  
  187.   
  188. <a href="#" onClick=window.close();return false)>关闭窗口</a>  
  189.   
  190. <a href="#" onClick=setTimeout(window.close(),3000)>3秒关闭本窗口</a>  
  191.   
  192. <script>  
  193. function shutwin(){   
  194. window.close();   
  195. return;}   
  196. </script>  
  197. <a href="javascript:shutwin();">关闭本窗口</a>  
  198.   
  199. <SPAN onClick="var strHref=window.location.href;this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.winliuxq.com/');" style="CURSOR: hand">设为首页</SPAN>  
  200.   
  201. 等于标题栏:<script>document.write(document.title);</script>  
  202.   
  203. <a href="javascript:void(0);" onClick='window.external.AddFavorite(location.href, document.title);'>收藏本页</a>  
  204.   
  205. <a href="javascript:window.external.AddFavorite(document.location.href, document.title)">收藏本页</a>  
  206.   
  207. <a href=javascript:window.external.addChannel("typhoon.cdf")>加入频道</a>  
  208.   
  209. <a href="i003.htm" onclick="return false;" ondblclick="window.open('i003.htm');">双击打开链接</a>  
  210.   
  211. <style>#close a:hover {background:url(javascript:window.opener=0;window.close());}</style><div id=close><a href="">关闭窗口</a></div>  
  212.   
  213. <A HREF="javascript:void(0)" onMouseover="alert('对不起,禁止选中!')">链接禁止</A>  
  214. <a href="" onMouseOver="alert('本站域名:http://www.winliuxq.com/');return true;">记住本站域名</a>  
  215.   
  216. 滚动条在左侧,将<html>改为<HTML DIR="RTL"> 
  217. ====================================================================================================
  218. 网页半透明   
  219. <body style="filter:Alpha(Opacity=50)">  
  220.   
  221. 随机选择背景色   
  222. <body>  
  223. <script>  
  224. document.body.style.background=(["red","blue","pink","navy","gray","yellow","green","purple"])[parseInt(Math.random()*8)];   
  225. </script>  
  226.   
  227. 框架页中不显示滚动条:   
  228. <SCRIPT>  
  229. self.moveTo(0,0)   
  230. self.resizeTo(screen.availWidth,screen.availHeight)   
  231. </SCRIPT>  
  232.   
  233. 防止网页被框架   
  234. <SCRIPT LANGUAGE=JAVASCRIPT>  
  235. if (top.location !== self.location) {   
  236. top.location=self.location;   
  237. }   
  238. </SCRIPT>  
  239.   
  240. 永远都会带着框架    
  241. <script language="javascript"><!--    
  242. if (window == top)top.location.href = "frame.htm"; //frame.htm为框架网页    
  243. // --></script>  
  244.   
  245. 窗口自动最大化   
  246. <script language="JavaScript"><!--   
  247. self.moveTo(0,0)   
  248. self.resizeTo(screen.availWidth,screen.availHeight)   
  249. //--></script>  
  250.   
  251. 打开窗口自动最大化   
  252. <OBJECT classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" onreadystatechange="if (this.readyState==4) this.Click();" VIEWASTEXT><PARAM name="Command" value="Maximize"></OBJECT>  
  253.   
  254. 爽眼闪屏代码   
  255. <script>var color = new Array;color[1] = "black";color[2] = "white";for(x = 0; x <3; x++){document.bgColor = color[x];if(x == 2){x = 0;}}</script>  
  256.   
  257. 不能被另存为   
  258. <noscript><iframe src=*.html></iframe></noscript>  
  259.   
  260. 汉字字库调用   
  261. <script>  
  262. for(i=19968;i<40870;i++)document.write(String.fromCharCode(i));   
  263. </script>  
  264.   
  265. 显示现在时间的脚本    
  266. <script language=vbscript>document.write now</script>  
  267.   
  268. 显示最后修改时间的脚本    
  269. <script>document.write(document.lastModified)</script>    
  270.   
  271. 按下F12键,直接返回首页    
  272. <script>function look(){    
  273. if(event.keyCode==123){document.location.href=http://www.winliuxq.com/}    
  274. }    
  275. if(document.onkeydown==null)    
  276. {document.onkeydown=look}    
  277. </script>    
  278.   
  279. 端口检测   
  280. <img src="http://www.winliuxq/zza.jpg" onload="alert('端口可用')" onerror="alert('端口禁止')"...>  
  281.   
  282. 无法最小化的窗口   
  283. <body onblur='self.focus();'>  
  284.   
  285. 链接点外部css文件   
  286. <style>@import url("ie.css");</style>  
  287.   
  288. 内嵌式框架-网页中调用另外网页:   
  289. <object type="text/x-scriptlet" width="600"  height="1000" data="http://www.winliuxq.com/"></object>  
  290.   
  291. 刷新改变窗口大小   
  292. <OBJECT classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" onreadystatechange="if (this.readyState==4) this.Click();" VIEWASTEXT><PARAM name="Command" value="Maximize"></OBJECT>  
  293.   
  294. JavaScript实现网页竖虚线   
  295. <script>hei=120;d1=2;d2=2;cou=Math.floor(hei/(d1+d2));   
  296. document.write('<table cellspacing=0 cellpadding=0 width=1 height='+hei+'>');   
  297. for(i=0;i<cou;i++){document.write('<tr><td height='+d2+'><tr><td height='+d1+' bgcolor=333333>')}</script></table>  
  298.   
  299. js翻页   
  300. <script>document.write("<a href="+location.href.replace(//.html/g,"_2.html")+">2</a>");</script> 
  301.  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值