Some common auxiliary code
Click to return to the previous page code:
<form>
<p><input type= "button" value= "Back" onclick= "History.back ( -1)" ></p>
</form>
Pop-up warning Box code:
<form>
<p><input type= "button" value= "Pop-up Warning box" onclick= "Alertbutton ()" ></p>
</form>
<script language= "JavaScript" ><!--
function Alertbutton () {Window.alert! ");}
--></script>
Click to open a new window
<form>
<p><input type= "button" value= "open new Window" onclick= "NewWindow ()" ></p>
</form>
<script language= "JavaScript" ><!--
function NewWindow () {window.open ("http://www.mcmx.com", "", "height=240,width=340,status=no,location=no,toolbar= No,directories=no,menubar=no ");}
--></script></body>
Pop-up confirmation box when deleting a record:
<script language= "VBSCRIPT" >
A=msgbox ("Do you really want to delete this record?") ", 1," note ")
If A=1 Then
location= "dodelete.asp?id=<%=id%>"//point to the page performing the deletion dodelete.asp
Else
History.go (-1)
End If
</script>
Close an open window
< a href= "/" onclick= "javascript:window.close (); return false; > Close Window </a>
Empty input and select
onclick= "javascript:this.value=" "onfocus=" This.select () "onmouseover=" This.focus () "
Right-click Mask
<body oncontextmenu=self.event.returnvalue=false>
How to solve the line-wrapping in English IE5.5
Style= "left:0px; width:100%; Word-wrap:break-word "You can modify to a specified size such as 200px
Picture "Reset" button
<script language= "JScript" >
function Myreset ()
{Document.login.reset ();
Document.login.focus ();}
</script>
Draw a thin form
<table style= "Border-collapse:collapse" >
Status bar Information
<form>
<p><input type= "button" value= "status bar Info" onclick= "Statusbutton ()" ></p>
</form>
<script language= "JavaScript" ><!--
function Statusbutton () {window.status= "to visit!" ";}
--></script>
Minimize, maximize, close windows
<object id=hh1 classid= "Clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" >
<param name= "Command" value= "Minimize" ></object>
<object id=hh2 classid= "Clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" >
<param name= "Command" value= "Maximize" ></object>
<object id=hh3 classid= "Clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" >
<param name= "Command" value= "Close" ></OBJECT>
<input Type=button value= Minimize onclick=hh1. Click () >
<input Type=button value= maximize ONCLICK=HH2. Click () >
<input Type=button value= closes Onclick=hh3. Click () >
This example applies to IE
Hide link information appearing in the status bar
<a href= "http://"; Onmouseover= "window.status= ' None '; return true" > Dream Sky </a>
text box Auto scroll bar
<textarea name=words rows=18 cols=26 style= "border:1 solid #000000; font-size:9pt; width:188; Overflow:auto "wrap=hard></textarea>
Select All and copy
<form name=test><input onclick= "Javascript:highlightall (' Test.select1 ')" Type=button value= Select all and copy >< Br><textarea name=select1 rows=3 cols=46> Hello, welcome to your visit! </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>
Masking JavaScript errors
<script language= "JavaScript" >
<!--
function Killerrors () {
return true;
}
Window.onerror = killerrors;
-->
</script>
Refresh parent window when child window is closed
<script language= "JavaScript" >
<!--
Self.opener.location.reload ();
Window.close ()
-->
</script>
Background color transformation
<form>
<p><input type= "button" value= "Background color transform" onclick= "Bgbutton ()" ></p>
</form>
<script>function Bgbutton () {
if (document.bgcolor== ' #00ffff ')
{document.bgcolor= ' #ffffff ';}
Else{document.bgcolor= ' #00ffff ';}
}
</script>
Check whether a string of strings is composed entirely of digits
<script language= "Javascript" ><!--
function Checknum (str) {return Str.match (//d/) ==null}
Alert (Checknum ("1232142141"))
Alert (Checknum ("123214214A1"))
--></script>
Current 1/2 page
12 Next read the full text