辅助代码
点击返回上页代码:
复制代码 代码如下:
<form>
<p><input TYPE="button" VALUE="返回上一步"></p>
</form>
弹出警告框代码:
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
点击打开新窗口
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
删除记录时弹出确认框:
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
关闭打开的窗口
<a href="https://www.jb51.net/">关闭窗口</a>
清空INPUT且选定
onClick="javascript:this.value=''" onFocus="this.select()"
右键屏蔽
<body oncontextmenu=self.event.returnValue=false>
连串英文自动换行的解决方法 IE5.5
style="LEFT: 0px; WIDTH: 100%; WORD-WRAP: break-word" 你可修改为指定的大小如 200px
图片"重置"按钮
<script language="jscript">
function myreset()
{ document.login.reset();
document.login.focus();}
</script>
<img src="https://www.jb51.net/image/reclear.gif" onfocus="this.blur()">
画细线表格
<table>
状态栏信息
<form>
<p><input TYPE="button" VALUE="状态栏信息"></p>
</form>
<script language="JavaScript"><!--
function StatusButton(){window.status="要多多光临呀!";}
// --></script>
最小化、最大化、关闭窗口
<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param value="Minimize"></object>
<object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param value="Maximize"></object>
<OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM VALUE="Close"></OBJECT>
<input type=button value=最小化 onclick=hh1.Click()>
<input type=button value=最大化 onclick=hh2.Click()>
<input type=button value=关闭 onclick=hh3.Click()>
本例适用于IE
隐藏状态栏里出现的LINK信息
<a href="https://";>梦想天空</a>
文本框自动滚动条
<textarea name=words rows=18 cols=26 wrap=hard></textarea>
全选并复制
<FORM name=test><INPUT type=button value=全选并复制><BR><TEXTAREA name=select1 rows=3 cols=46>你好,欢迎您的光临!</TEXTAREA>
</FORM>
<SCRIPT language=Javascript>
<!--
var copytoclip=1
function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
if (document.all&©toclip==1){
therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status="Contents highlighted and copied to clipboard!"
setTimeout("window.status=''",1800)
}
}
//-->
</SCRIPT>
屏蔽JAVASCRIPT错误
<script language="JavaScript">
<!--
function killErrors(){
return true;
}
window.onerror = killErrors;
-->
</script>
关闭子窗口时刷新父窗口
<script language="JavaScript">
<!--
self.opener.location.reload();
window.close()
-->
</script>
背景色变换
<form><p><input TYPE="button" VALUE="背景色变换"></p>
</form>
<script>function BgButton(){
if (document.bgColor=='#00ffff')
{document.bgColor='#ffffff';}
else{document.bgColor='#00ffff';}
}
</script>
检查一段字符串是否全由数字组成
<script language="Javascript"><!--
function checkNum(str){return str.match(//D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>
判断是否是字符
if (/[^/x00-/xff]/g.test(s)) alert("含有汉字");
点击刷新代码:
<form>
<p><input TYPE="button" VALUE="刷新按钮一"></p>
</form>
<script language="JavaScript"><!--
function ReloadButton(){location.href="allbutton.htm";}
// --></script>
让层不被控件复盖代码:
<div z-Index:2><object xxx></object></div> # 前面
<div z-Index:1><object xxx></object></div> # 后面
<div><table height=100% width=100% bgcolor="#ff0000"><tr><td height=100% width=100%></td></tr></table><iframe width=0 height=0></iframe></div>
<div><iframe height=100% width=100%></iframe></div>
让层的相对定位
<div>
<div>
内容
</div></div>
Flash代码以及背景透明
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0">
<param value="文件">
<param value="high">
<param value="transparent">
<embed src="https://www.jb51.net/images/fish.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>
Windows Media Player 播放器
<OBJECT id=MediaPlayer1
style="LEFT: 0px; VISIBILITY: visible; POSITION: absolute; TOP: 0px;z-index:2"
codeBase=https://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701standby=
Loading
type=application/x-oleobject height=300 width=320
classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 VIEWASTEXT>
<PARAM VALUE="地址">
<param value="-1">
<param value="0">
<param value="-1">
<param value="0">
<param value="-1">
<param value="-1">
<param value="0">
<param value="0">
<param value>
<param value="5">
<param value>
<param value="-1">
<param value="0">
<param value="-1">
<param value="0">
<param value>
<param value="0">
<param value="16777215">
<param value="0">
<param value="4">
<param value="-1">
<param value="-1">
<param value="0">
<param value="0">
<param value="-1">
<param value="-1">
<param value="-1">
<param value="0">
<param value="1">
<param value="0">
<param value="1">
<param value>
<param value>
<param value>
<param value="-1">
<param value="-1">
<param value="-1">
<param value="-1">
<param value="-1">
<param value="0">
<param value="0">
<param value="0">
<param value="-1">
<param value="0">
<param value="-1">
<param value="-1">
<param value="0">
<param value="0">
<param value="-1">
<param value="-1">
<param value="-1">
<param value="-1">
<param value="0">
<param value="0">
<param value="0">
<param value="70">
<param value="0">
</OBJECT>
RealPlayer 播放器
<object id=video1 classid=" clasid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"
width=320 height=240>
<param value="inagewindow">
<param value="chicp1">
<param value="true">
<param value="地址">
<embed
src="地址"
type="audio/x-pn-realaudio-plugin" console="chip1"
controls="imagewindow" width=320 height=240 autostart=true>
</embed>
</object>