日期:2014-05-16 浏览次数:20367 次
来兄弟连两个多月,目前接触了PHP/Shell/JS三种编程语言了,我发现语言之间有共性,但也有区别,所以要总结共性,注重学习语言之间的非共同点。
同一语言更应多多总结,这样能起到事半功倍的效果,下面总结整理JS各常用功能:
后退 前进
<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.yourName.com/;}</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()>
链接按钮1
<input type="button" value="链接按钮 1" onClick="window.open('http://www.yourName.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.yourName.com/')">
链接按钮3
<input type="submit" value="链接按钮3" onClick="location.href='http://www.yourName.com/'">
警告框显示源代码
<BUTTON onClick=alert(document.documentElement.outerHTML) style="width:110">警告框显示源代码</BUTTON>
点击后按钮清空
<input type=button value='打印' onClick="this.style.visibility='hidden