`
xiaolong0211
  • 浏览: 329260 次
  • 性别: Icon_minigender_1
  • 来自: 青岛
社区版块
存档分类
最新评论

常用js(转)

阅读更多

原文链接:http://huagenli.iteye.com/blog/513674

1、后退 前进  

<input 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:" +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="刷新按钮二" onClick="history.go(0)">  

 

6、回首页按钮  

<input type="button" value="首页" onClick="HomeButton()">  

<script>function HomeButton(){location.href=http://www.winliuxq.com;}</script>  

 

7、弹出警告框  

<input type="button" value="弹出警告框" onClick="AlertButton()">  

<script>function AlertButton(){window.alert("要多多光临呀!");}</script>  

 

8、状态栏信息  

<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.bgColor=='#00ffff')  

    {document.bgColor='#ffffff';}  

else{document.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");}  

</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="全屏显示" 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();">  

 

关闭窗口  

<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 style="ime-mode:disabled" value=关闭输入法>

16、链接按钮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/'">  

 

17、警告框显示源代码  

<BUTTON onClick=alert(document.documentElement.outerHTML) style="width:110">警告框显示源代码</BUTTON>  

 

18、点击后按钮清空  

<input 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=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、点击自动复制  

<script>function oCopy(obj){obj.select();js=obj.createTextRange();js.execCommand("Copy")}</script>  

<input type="text" value="点击自动复制" onClick="oCopy(this)" size="11">  

 

23、自动选中  

<input value="自动选中" onFocus="this.select()" on ouseOver="this.focus()" size="11">  

 

24、打开源代码  

<BUTTON on lick="document.location = 'view-source:' + document.location" size="7">打开源代码</BUTTON>  

 

25、新窗口延迟打开  

<input type=button value=新窗口延迟打开 on lick=javascript:setTimeout("window.open('http://www.winliuxq.com/')",10000)>  

 

26、实现选中文本框里的前一半的内容  

<input type="text" value="选中文本框里的前一半的内容" size=30 on ouseover="this.select();tR=document.selection.createRange();tR.moveEnd('character',-8);tR.select();">  

<input type="text" value="选中部分内容,非IE可以用这个" size=30 on ouseover="this.selectionStart=this.value.length-4;this.selectionEnd=this.value.length">  

    

27、点击清空文字  

<input type="text" name="artist" size=14 value="点击清空文字" on ouseover=this.focus() on ocus=this.select() on lick="if(this.value=='点击清空文字')this.value=''">  

 

点击清空文字  

<input name=name size=11 value=点击清空文字 on ouseOver=this.focus() on lur="if (this.value =='') this.value='点击清空文字'" on ocus=this.select() on lick="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="测试" on lick="alert(window.navigator.on ine)">  

 

30、11种刷新按钮的方法  

<input type=button value=刷新 on lick="history.go(0)">  

<input type=button value=刷新 on lick="location.reload()">  

<input type=button value=刷新 on lick="location=location">  

<input type=button value=刷新 on lick="location.assign(location)">  

<input type=button value=刷新 on lick="document.execCommand('Refresh')">  

<input type=button value=刷新 on lick="window.navigate(location)">  

<input type=button value=刷新 on lick="location.replace(location)">  

<input type=button value=刷新 on lick="window.open('自身的文件','_self')">  

<input type=button value=刷新 on lick=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=刷新 on lick="a1.click()">

31、  

<a href="#" on lick=document.execCommand("open")>打开</a>

32、

<a on lick="window.open('i001.htm','','height=300,width=300,resizable=no,location=net');" href="">打开指定大小网页</a>

33、

<a href="#" on lick=location.replace("view-source:"+location)>使用 记事本 编辑</a> 

 

34、

<a href="#" on lick=document.execCommand("saveAs")>另存为</a> 

 

35、

<a href="#" on lick=document.execCommand("print")>打印</a> 

<a href="javascript:window.print();">打印</a> 

 

36、

<a href=mailto:429752806@163.com>发送E-mail</a> 

 

37、

<a href="#" on lick=document.execCommand("selectAll")>全选</a> 

 

38、

<a href="#" on lick=location.reload()>刷新1</a> 

 

39、

<a href="#" on lick=history.go(0)>刷新2</a> 

 

40、

<a href="#" on lick=location.replace("view-source:"+location)>查看源文件</a> 

 

41、

<a href="#" on lick=window.open(document.location,"url","fullscreen")>全屏显示</a> 

 

42、

<a href="#" on lick=window.external.showBrowserUI("PrivacySettings",null)>internet选项</a> 

 

43、

<a href="#" on ontextmenu="window.open(this.href);return false;">单击右键将在新窗口中打开</a> 

 

44、

<a href="#" on lick=history.go(1)>前进1</a> 

 

<a href="#" on lick=history.forward()>前进2</a> 

 

<a href="#" on lick=history.go(-1)>后退1</a> 

 

<a href="#" on lick=history.back()>后退2</a> 

 

45、

<a href="#" on lick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夹</a> 

 

<SPAN on lick="window.external.addFavorite('http://www.winliuxq.com/','网页特效站点')" style="CURSOR: hand" title=网页特效站点>加入收藏</SPAN>

<a href="#" on lick="window.external.addFavorite('http://www.winliuxq.com/','网页特效站点')">添加到收藏夹</A> 

 

<a href="javascript:window.external.AddFavorite('http://www.winliuxq.com/', '网页特效站点')">点击加入收藏夹</a> 

 

<a href="#" on ouseover="window.external.addFavorite('http://www.winliuxq.com/','网页特效站点')" target="_self" >鼠标感应收藏本站</a> 

 

<a href="#" on ouseover="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.yiloo.com/js/');" target="_self">鼠标感应设为首页</a>  

46、

<a href="javascript:window.close()">关闭窗口</a> 

 

<a href="#" on lick=window.close();return false)>关闭窗口</a> 

 

<a href="#" on lick=setTimeout(window.close(),3000)>3秒关闭本窗口</a> 

 

<script> 

function shutwin(){  

window.close();  

return;}  

</script> 

<a href="javascript:shutwin();">关闭本窗口</a> 

 

47、<SPAN on lick="var strHref=window.location.href;this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.winliuxq.com/');" style="CURSOR: hand">设为首页</SPAN> 

 

48、等于标题栏:<script>document.write(document.title);</script> 

 

49、

<a href="javascript:void(0);" on lick='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> 

 

50、

<a href="i003.htm" on lick="return false;" on blclick="window.open('i003.htm');">双击打开链接</a> 

 

51、

<style>#close a:hover {background:url(javascript:window.opener=0;window.close());}</style><div id=close><a href="">关闭窗口</a></div> 

 

52、

<A HREF="javascript:void(0)" on ouseover="alert('对不起,禁止选中!')">链接禁止</A> 

53、滚动条在左侧,将<html>改为<HTML DIR="RTL"> 

54、网页半透明  

<body style="filter: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、防止网页被框架  

<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、窗口自动最大化  

<script language="JavaScript"><!--  

self.moveTo(0,0)  

self.resizeTo(screen.availWidth,screen.availHeight)  

//--></script> 

 

60、打开窗口自动最大化  

<OBJECT classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" on eadystatechange="if (this.readyState==4) this.Click();" VIEWASTEXT><PARAM name="Command" value="Maximize"></OBJECT> 

61、爽眼闪屏代码

<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> 

 

62、不能被另存为  

<noscript><iframe src=*.html></iframe></noscript> 

 

63、汉字字库调用  

<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键,直接返回首页   

<script>function look(){   

if(event.keyCode==123){document.location.href=http://www.winliuxq.com/}   

}   

if(document.on eydown==null)   

{document.on eydown=look}   

</script>   

 

67、端口检测

<img src="http://www.winliuxq/zza.jpg" on oad="alert('端口可用')" on rror="alert('端口禁止')"...> 

 

68、无法最小化的窗口  

<body on lur='self.focus();'> 

 

69、链接点外部css文件  

<style>@import url("ie.css");</style> 

 

70、内嵌式框架-网页中调用另外网页:  

<object type="text/x-scriptlet" width="600"  height="1000" data="http://www.winliuxq.com/"></object> 

 

71、刷新改变窗口大小  

<OBJECT classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" on eadystatechange="if (this.readyState==4) this.Click();" VIEWASTEXT><PARAM name="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>

分享到:
评论

相关推荐

    常用 js 大全常用 js 大全常用 js 大全常用 js 大全常用 js 大全

    6. 一 个 小 写 转 大 写 的 & #106s: document.getElementByI document.getElementById("input").&#118alue.toUpperCase(); 7.JS 中的值类型:String,Number,Boolean,Null,Object,Function 8.JS 中的字符型转换成...

    73种网页常用js代码

    73种网页常用js代码,转自某个群。目前还算挺实用的

    javascript最常用数据类型转换(最全).doc

    这些类型之间可以进行转换,以下是 JavaScript 中最常用的数据类型转换方法。 一、转为字符串 在 JavaScript 中,可以使用两种方法将其他类型转换为字符串类型:toString() 方法和 String() 方法。 1. toString()...

    40种网站常用Javascript技巧

    40种网站常用Javascript技巧. 转至http://blog.csdn.net/cyp403/archive/2007/02/25/1514038.aspx

    常用javascript案例大全

    JavaScript 是一种广泛应用于 Web 开发中的脚本语言,下面是常用的 JavaScript 案例大全,包括原生 JavaScript 实现字符串长度截取、获取域名主机、清除空格、替换全部、转义 HTML 标签、还原 HTML 标签、时间日期...

    常用JavaScript命令大全

    "JavaScript 命令大全" JavaScript 是一种广泛使用的脚本语言,主要用于客户端的脚本编程。下面是 JavaScript 命令大全,涵盖了 JavaScript 的基本语法、变量、数据类型、运算符、控制结构、函数、数组、字符串、...

    js实现坐标系之间的转换,包括常用wgs84,GCj02,BD09等相关

    js实现坐标系之间的转换,包括常用wgs84,GCj02,BD09等相关

    107个常用Javascript语句.doc

    本文档总结了107个常用的Javascript语句,涵盖了Javascript的基础知识点,包括输出语句、注释、HTML文档结构、DOM顺序、表单元素的获取、字符串操作、数字操作、比较操作符、变量声明、判定语句、循环结构、函数定义...

    js数据类型转换

    常用的js数据类型转换函数parseInt

    常用CS类库(字符串操作类,数据库操作类,邮件发送类,正则类,对象转换类,文件操作类,常用JS操作类,Office操作类等等)

    常用CS类库(字符串操作类,数据库操作类,邮件发送类,正则类,对象转换类,文件操作类,常用JS操作类,Office操作类等等)

    js常用代码

    javascript常用代码 JavaScript是一种广泛使用的脚本语言,主要用于客户端脚本编程。下面是JavaScript中的一些常用代码,涵盖了事件处理、DOM操作、字符串处理、CSS样式设置、表单操作等方面。 事件处理 * 获取...

    常用js方法

    大小写转换 字符串处理 日期格式 流处理 常用正则表达式 常用js

    常用javascript语句大全

    2.JS中的注释为// 3.传统的HTML文档顺序是:document-&gt;html-&gt;(head,body) 4.一个浏览器窗口中的DOM顺序是:window-&gt;(navigator,screen,history,location,document) 5.得到表单中元素的名称和值:document....

    javascript常用整理

    6.一个小写转大写的JS: document.getElementById("output").value = document.getElementById("input").value.toUpperCase(); 7.JS中的值类型:String,Number,Boolean,Null,Object,Function 8.JS中的字符型转换成数值...

    常用js大全,javascript校验大全

    js大全 . 1.1 全是数字.. 3 1.2 限制 期限 不能大于 100 年.. 4 1.3 将日期格式由yyyy-MM-dd,转换为yyyymmdd,以直接比较两个日 期的大小.. 4 1.4 判断字符串是否全部由数字组成. 5 1.5 判断字符串是否全部由字母...

    107个常用javascript语句

    107个常用javascript语句 -7.焦点 .focus(); -6.捕获对象通用方法 function $(obj) {return document.getElementById(obj);} ("") %&gt; -5.字符串赋值数组var array=new Array(); array=tdrczpdata.split('&lt;BR&gt;'); ...

    Javascript的常用语句

    Javascript的常用语句 1.document.write( " "); 输出语句 2.JS中的注释为// 3.传统的HTML文档顺序是:document- &gt;html- &gt;(head,body) 4.一个浏览器窗口中的DOM顺序是:window- &gt;(navigator,screen,history,...

    100多个基础常用JS函数和各种数据转换处理集合大全.zip

    100多个基础常用JS函数和各种数据转换处理集合大全,此工具包是在 outils 的基础上,加上个人平时收集的代码片段进行的二次整合

    网站上常用的图片翻转JS效果

    网站上常用的图片翻转效果,图片数量没有限制,两个标题在效果层上,样式完全通过修改CSS样式。

    【KETTLE教材】JS内嵌方法

    其中,JavaScript是一种常用的脚本语言,用于在KETTLE中执行各种操作。在KETTLE中,JavaScript可以用于实现各种数据处理任务,如字符串操作、日期操作、加密解密等。本文将详细介绍KETTLE中的JavaScript内嵌方法。 ...

Global site tag (gtag.js) - Google Analytics