`
haimav
  • 浏览: 57166 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

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

    博客分类:
  • html
阅读更多

脚本说明:

  • 把如下代码加入<body>区域中:
  • 后退 前进
  • <input type="button" value="后退" onClick="history.go(-1)">
  • <input type="button" value="前进" onClick="history.go( 1 );return true;">
  • 返回
  • <form><input type="button" value="返回上一步" onClick="history.back(-1)"></form>
  • 查看源码
  • <input type="button" name="view" value="查看源码" onClick="window.location="view-source:" +window.location.href">
  • 禁止查看源码
  • <body oncontextmenu="return false"></body>
  • 刷新按钮一
  • <input type="button" value="刷新按钮一" onClick="ReloadButton()">
  • <script>function ReloadButton(){location.href="i001.htm";}</script>
  • 刷新按钮二
  • <input type="button" value="刷新按钮二" onClick="history.go(0)">
  • 回首页按钮
  • <input type="button" value="首页" onClick="HomeButton()">
  • <script>function HomeButton(){location.href=http://www.winliuxq.com/;}</script>
  • 弹出警告框
  • <input type="button" value="弹出警告框" onClick="AlertButton()">
  • <script>function AlertButton(){window.alert("要多多光临呀!");}</script>
  • 状态栏信息
  • <input type="button" value="状态栏信息" onClick="StatusButton()">
  • <script>function StatusButton(){window.status="要多多光临呀!";}</script>
  • 背景色变换
  • <form><input type="button" value="背景色变换" onClick="BgButton()"></form>
  • <script>function BgButton(){
  • if (document.bgColor=='#00ffff')
  • {document.bgColor='#ffffff';}
  • else{document.bgColor='#00ffff';}
  • }
  • </script>
  • 打开新窗口
  • <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");}
  • </script>
  • 窗口最小化
  • <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>
  • 全屏代码
  • <input type="BUTTON" name="FullScreen" value="全屏显示" onClick="window.open(document.location, 'butong_net', 'fullscreen')">
  • 关闭窗口
  • <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();">
  • 关闭窗口
  • <input type=button value=关闭窗口 onClick="javascript:self.close()">
  • 最大化
  • <object id=big classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
  • <param name="Command" value="Maximize"></object><input type=button value=最大化 onClick=big.Click()>
  • 关闭输入法
  • <input style="ime-mode:disabled" value=关闭输入法>
  • 链接按钮1
  • <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">
  • 链接按钮2
  • <input type="BUTTON" NAME="Button" value="链接按钮2" onClick="showModalDialog('http://www.winliuxq.com/')">
  • 链接按钮3
  • <input type="submit" value="链接按钮3" onClick="location.href='http://www.winliuxq.com/'">
  • 警告框显示源代码
  • <BUTTON onClick=alert(document.documentElement.outerHTML) style="width:110">警告框显示源代码</BUTTON>
  • 点击后按钮清空
  • <input type=button value='打印' onClick="this.style.visibility='hidden';window.print();">
  • 打印
  • <input type=button value='打印' onClick="window.print();">
  • 打印预览
  • <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>
  • <input type=button value=打印预览 onclick="wb.execwb(7,1)">
  • 另存为
  • <input onClick="document.execCommand('saveas','true','常用代码.htm')" type=button value=另存为>
  • 点击自动复制
  • <script>function oCopy(obj){obj.select();js=obj.createTextRange();js.execCommand("Copy")}</script>
  • <input type="text" value="点击自动复制" onClick="oCopy(this)" size="11">
  • 自动选中
  • <input value="自动选中" onFocus="this.select()" onMouseOver="this.focus()" size="11">
  • 打开源代码
  • <BUTTON onClick="document.location = 'view-source:' + document.location" size="7">打开源代码</BUTTON>
  • 新窗口延迟打开
  • <input type=button value=新窗口延迟打开 onClick=javascript:setTimeout("window.open('http://www.winliuxq.com/')",10000)>
  • 实现选中文本框里的前一半的内容
  • <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.selectionEnd=this.value.length">
  • 点击清空文字
  • <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='点击清空文字'" onFocus=this.select() onClick="if (this.value=='点击清空文字 ') this.value=''">
  • 等于标题(title):
  • <input type="text" value="" id="aa" size="20">
  • <script>document.getElementById("aa").value=document.title;</script>
  • 检测IE是否脱机
  • <input type="button" value="测试" onclick="alert(window.navigator.onLine)">
  • 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=button 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=button 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=button value=刷新 onClick="a1.click()">

     

  •  

  • =========================================================================================================
  • 脚本说明:
  • 把如下代码加入<body>区域中:
  • <a href="#" onClick=document.execCommand("open")>打开</a>
  • <a onclick="window.open('i001.htm','','height=300,width=300,resizable=no,location=net');" href="">打开指定大小网页</a
  • <a href="#" onClick=location.replace("view-source:"+location)>使用 记事本 编辑</a>
  • <a href="#" onClick=document.execCommand("saveAs")>另存为</a>
  • <a href="#" onClick=document.execCommand("print")>打印</a>
  • <a href="javascript:window.print();">打印</a>
  • <a href=mailto:429752806@163.com>发送E-mail</a>
  • <a href="#" onClick=document.execCommand("selectAll")>全选</a>
  • <a href="#" onClick=location.reload()>刷新1</a>
  • <a href="#" onClick=history.go(0)>刷新2</a>
  • <a href="#" onClick=location.replace("view-source:"+location)>查看源文件</a>
  • <a href="#" onClick=window.open(document.location,"url","fullscreen")>全屏显示</a>
  • <a href="#" onClick=window.external.showBrowserUI("PrivacySettings",null)>internet选项</a>
  • <a href="#" oncontextmenu="window.open(this.href);return false;">单击右键将在新窗口中打开</a>
  • <a href="#" onClick=history.go(1)>前进1</a>
  • <a href="#" onClick=history.forward()>前进2</a>
  • <a href="#" onClick=history.go(-1)>后退1</a>
  • <a href="#" onClick=history.back()>后退2</a>
  • <a href="#" onClick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夹</a>
  • <SPAN onClick="window.external.addFavorite('http://www.winliuxq.com /','网页特效站点')" style="CURSOR: hand" title=网页特效站点>加入收藏</SPAN>
  • <a href="#" onClick="window.external.addFavorite('http://www.winliuxq.com/','网页特效站点')">添加到收藏夹</A>
  • <a href="javascript:window.external.AddFavorite('http://www.winliuxq.com/', '网页特效站点')">点击加入收藏夹</a>
  • <a href="#" onmouseover="window.external.addFavorite('http://www.winliuxq.com /','网页特效站点')" target="_self" >鼠标感应收藏本站</a>
  • <a href="#" onmouseover="this.style.behavior='url(#default#homepage)'; this.setHomePage('http://www.yiloo.com/js/');" target="_self">鼠标感应设为首页</a>
  • <a href="javascript:window.close()">关闭窗口</a>
  • <a href="#" onClick=window.close();return false)>关闭窗口</a>
  • <a href="#" onClick=setTimeout(window.close(),3000)>3秒关闭本窗口</a>
  • <script>
  • function shutwin(){
  • window.close();
  • return;}
  • </script>
  • <a href="javascript:shutwin();">关闭本窗口</a>
  • <SPAN onClick="var strHref=window.location.href; this.style.behavior='url(#default#homepage)'; this.setHomePage('http://www.winliuxq.com/');" style="CURSOR: hand">设为首页</SPAN>
  • 等于标题栏:<script>document.write(document.title);</script>
  • <a href="javascript:void(0);" onClick='window.external.AddFavorite(location.href, document.title);'>收藏本页</a>
  • <a href="javascript:window.external.AddFavorite(document.location.href, document.title)">收藏本页</a>
  • <a href=javascript:window.external.addChannel("typhoon.cdf")>加入频道</a>
  • <a href="i003.htm" onclick="return false;" ondblclick="window.open('i003.htm');">双击打开链接</a>
  • <style>#close a:hover {background:url(javascript:window.opener=0; window.close());}</style><div id=close><a href="">关闭窗口</a></div>
  • <A HREF="javascript:void(0)" onMouseover="alert('对不起,禁止选中!')">链接禁止</A>
  • <a href="" onMouseOver="alert('本站域名:http://www.winliuxq.com/');return true;">记住本站域名</a>
  • 滚动条在左侧,将<html>改为<HTML DIR="RTL">

     

  • ====================================================================================================
  • 网页半透明
  • <body style="filter:Alpha(Opacity=50)">
  • 随机选择背景色
  • <body>
  • <script>
  • document.body.style.background=(["red","blue","pink","navy","gray","yellow","green","purple"])[parseInt(Math.random()*8)];
  • </script>
  • 框架页中不显示滚动条:
  • <SCRIPT>
  • self.moveTo(0,0)
  • self.resizeTo(screen.availWidth,screen.availHeight)
  • </SCRIPT>
  • 防止网页被框架
  • <SCRIPT LANGUAGE=JAVASCRIPT>
  • if (top.location !== self.location) {
  • top.location=self.location;
  • }
  • </SCRIPT>
  • 永远都会带着框架
  • <script language="javascript"><!--
  • if (window == top)top.location.href = "frame.htm"; //frame.htm为框架网页
  • // --></script>
  • 窗口自动最大化
  • <script language="JavaScript"><!--
  • self.moveTo(0,0)
  • self.resizeTo(screen.availWidth,screen.availHeight)
  • //--></script>
  • 打开窗口自动最大化
  • <OBJECT classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" onreadystatechange="if (this.readyState==4) this.Click();" VIEWASTEXT><PARAM name="Command" value="Maximize"></OBJECT>
  • 爽眼闪屏代码
  • <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>
  • 不能被另存为
  • <noscript><iframe src=*.html></iframe></noscript>
  • 汉字字库调用
  • <script>
  • for(i=19968;i<40870;i++)document.write(String.fromCharCode(i));
  • </script>
  • 显示现在时间的脚本
  • <script language=vbscript>document.write now</script>
  • 显示最后修改时间的脚本
  • <script>document.write(document.lastModified)</script>
  • 按下F12键,直接返回首页
  • <script>function look(){
  • if(event.keyCode==123){document.location.href=http://www.winliuxq.com/}
  • }
  • if(document.onkeydown==null)
  • {document.onkeydown=look}
  • </script>
  • 端口检测
  • <img src="http://www.winliuxq/zza.jpg" onload="alert('端口可用')" onerror="alert('端口禁止')"...>
  • 无法最小化的窗口
  • <body onblur='self.focus();'>
  • 链接点外部css文件
  • <style>@import url("ie.css");</style>
  • 内嵌式框架-网页中调用另外网页:
  • <object type="text/x-scriptlet" width="600" height="1000" data="http://www.winliuxq.com/"></object>
  • 刷新改变窗口大小
  • <OBJECT classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" onreadystatechange="if (this.readyState==4) this.Click();" VIEWASTEXT><PARAM name="Command" value="Maximize"></OBJECT>
  • 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>
  • js翻页
  • <script>document.write("<a href="+location.href.replace(/\.html/g,"_2.html")+">2</a>");</script>
  • 分享到:
    评论

    相关推荐

      selenium右击另存为图片

      一种方法是模拟JavaScript事件来触发右键菜单,然后模拟选择“另存为”选项。这里我们假设图片元素的ID为`image_id`: 1. **获取图片元素**: ```python image_element = driver.find_element_by_id('image_id')...

      JavaScript实现控制打开文件另存为对话框的方法

      本文主要讲述了使用JavaScript实现打开文件另存为对话框的方法,提供了相关的技术实现和实例分析。知识点主要涵盖以下几个方面: 1. **JavaScript控制文件另存为对话框的技术原理:** 文中提出了一种利用...

      Js网页另存为实现代码

      ### Js网页另存为实现代码 #### 知识点概览 本文将详细介绍如何使用JavaScript实现网页另存为的功能。具体来说,我们将探讨两种方法:一种是基于IE内核浏览器的实现方式,另一种则适用于更广泛的浏览器环境。此外,...

      web开发中常用的input事件汇总

      ### Web开发中常用的Input事件汇总 在Web开发中,`&lt;input&gt;`元素是与用户交互的重要组成部分之一。本文将详细解读一系列与`&lt;input&gt;`相关的事件及其应用案例,特别是通过JavaScript来实现各种实用功能。 #### 打开...

      JavaScript经典代码大全

      JavaScript经典代码大全是一份汇集了各种JavaScript编程技巧和实用脚本的资源集合,对于学习和提升JavaScript编程技能非常有帮助。以下将详细解释其中的一些重要知识点: 1. 右键菜单控制:`oncontextmenu="window....

      javascript的常用代码

      以下是一些JavaScript的常用代码示例及其详细解释: 1. `oncontextmenu="window.event.returnValue=false"`:这个代码用于禁用浏览器的右键菜单。当用户尝试在页面元素上点击右键时,事件会被阻止,从而防止默认的...

      Javascript代码收藏大全

      JavaScript代码收藏大全中包含了一系列实用的JavaScript技巧和方法,这些技巧涵盖了网页交互、安全防护以及用户体验等多个方面。以下是对这些代码片段的详细解释: 1. `oncontextmenu="window.event.returnValue=...

      常用经典javascript代码集锦

      使用`&lt;object&gt;`标签和`ExecWB`方法,可以提供一个“另存为”按钮,让用户保存网页: ```html &lt;input type="button" name="Button" value="保存本页" onClick="document.all.button.ExecWB(4,1)"&gt; ...

      js代码收藏

      在上述的“js代码收藏”中,列举了一些常见的JavaScript代码片段,这些代码主要用于实现特定的网页交互效果和安全控制。下面对这些代码进行详细解释: 1. `oncontextmenu="window.event.returnValue=false"`:这个...

      JavaScript 经典代码大全

      5. `&lt;link rel="Shortcut Icon" href="favicon.ico"&gt;` 和 `&lt;link rel="Bookmark" href="favicon.ico"&gt;`:这两行代码用于设置网页的favicon,即浏览器标签页和收藏夹中的小图标。 6. `&lt;input style="ime-mode:-...

      javascript经典代码大全.pdf

      JavaScript 是一种广泛应用于Web开发的脚本语言,它在网页中负责处理用户交互、操作DOM(文档对象模型)以及与服务器进行数据交换等任务。在提供的文件内容中,列举了一些经典的JavaScript代码片段,这些代码主要...

      网页制作必备(最常用javascript onclick语句40条)

      下面将详细介绍给定文件中提及的40条最常用的 JavaScript onclick 语句,帮助网页开发者更好地理解和运用这些代码片段。 ### 1. 跳转到指定页面 ```html &lt;input type="button" name="Button" value="" onclick=...

      经典代码收藏

      这篇文章收藏了一些有用的JavaScript代码,涵盖了防止用户右键菜单、防止复制、粘贴、修改浏览器 favicon 等多个方面的经典代码。以下是对每个代码点的详细解释: 1.oncontextmenu="window.event.returnvalue=false...

      总结javescript打印

      JavaScript(JS)是一种广泛用于网页和网络应用的脚本语言,尤其在客户端浏览器环境中,它提供了许多功能,包括打印操作。本文将详细总结JavaScript中关于打印的一些关键知识点,以供日后参考。 一、JS自带的打印...

      40种窗体常用代码

      本文主要介绍的是40种窗体(网页)设计中常用的代码技巧,这些技巧涵盖了从用户交互、安全防护到页面控制等多个方面。以下是一些关键知识点的详细说明: 1. 右键菜单禁用:通过`oncontextmenu="window.event.return...

      JS代码大全,最全的网页代码效果.pdf

      这些JS代码片段展示了JavaScript在网页交互和安全控制方面的一些基本用法,但在实际开发中,需要注意兼容性问题,并且很多功能在现代浏览器中有更优的实现方式,如使用事件监听器和CSS属性等。随着Web技术的发展,...

      JS代码大全,最全的网页代码效果[归纳].pdf

      以上只是《JS代码大全,最全的网页代码效果[归纳].pdf》中的一部分内容,实际文档中可能还包含了更多关于JavaScript的实用技巧和示例,可以帮助开发者快速实现各种网页交互效果。对于JavaScript初学者或者希望提升...

      javascript代码大全.pdf

      这份"JavaScript代码大全.pdf"文档似乎包含了多种JavaScript的实用技巧和代码片段,涉及了用户界面交互、安全控制、页面元素操作等多个方面。下面我们将详细探讨这些知识点: 1. **鼠标右键菜单禁用**: 使用`...

      Javascript中最常用的55个经典技巧

      标题:“Javascript中最常用的55个经典技巧”,表明文档将介绍55个JavaScript中常见的、实用的技巧。 描述:文档整合了32页的PDF内容,详细讲解了55个技巧,包括屏蔽鼠标右键、防止文本复制、关闭输入法、窗口的...

      JS代码大全.pdf

      JavaScript,也被称为JS,是一种广泛应用于网页和网络应用的脚本语言,主要负责网页的动态交互功能。在上述内容中,列举了一些JavaScript的实用技巧和方法,这些技巧主要用于增强网页的用户体验和安全性。 1. `...

    Global site tag (gtag.js) - Google Analytics