Javascript| tips//Various sizes S + + "\ r \ n page visible area wide:" + document.body.clientWidth;
s + + "\ r \ n page visible Area High:" + document.body.clientHeight;
s + + "\ r \ n" page visible area High: "+ Document.body.offsetWeight +" (including the edge of the width);
s + + "\ r \ n" page visible area High: "+ Document.body.offsetHeight +" (including the edge of the width);
s + + "\ r \ n page text full text width:" + document.body.scrollWidth;
s + + "\ r \ n" page full text High: "+ document.body.scrollHeight;
s + + "\ r \ n Pages are rolled High:" + document.body.scrollTop;
s + + "\ r \ n page is rolled to the left:" + document.body.scrollLeft;
s + + "\ r \ n Page body part:" + window.screentop;
s + + "\ r \ n Page body part left:" + window.screenleft;
s + + "\ r \ n screen resolution of High:" + window.screen.height;
s + + "\ r \ n Screen resolution width:" + window.screen.width;
s + = "\ r \ n Screen available working area height:" + window.screen.availHeight;
s + = "\ r \ n Screen available working area width:" + window.screen.availWidth;
//Filter Digital <input type=text onkeypress= "Return event.keycode>=48&&event.keycode<=57| | (This.value.indexOf ('. ') <0?event.keycode==46:false) "onpaste=" Return!clipboarddata.getdata (' text '). Match (/\d/) "ondragenter=" return False ">
//Special purpose <input Type=button value= Import Favorites onclick= window.external.ImportExportFavorites (true, ' http:// localhost '); " >
<input Type=button value= Export Favorites onclick= "Window.external.ImportExportFavorites (False, ' http://localhost ');" >
<input Type=button value= Collection Folder onclick= "Window.external.ShowBrowserUI (' organizefavorites ', null)" >
<input Type=button value= Language Settings onclick= "Window.external.ShowBrowserUI (' Languagedialog ', null)" >
<input Type=button value= Add Favorites onclick= "Window.external.AddFavorite (' http://www.google.com/', ' Google ')" >
<input Type=button Value= added to channel onclick= "Window.external.addChannel (' http://www.google.com/')" >
<input Type=button Value= added to channel onclick= "Window.external.showBrowserUI (' privacysettings ', null)" >
//Do not cache <meta http-equiv= "pragma" content= "No-cache" >
<meta http-equiv= "Cache-control" content= "No-cache, must-revalidate" >
<meta http-equiv= "Expires" content= "0" >
//Regular match
Matching regular expressions for Chinese characters: [\U4E00-\U9FA5]
Match Double-byte characters (including Chinese characters): [^\x00-\xff]
A regular expression that matches a blank row: \n[\s|] *\r
Regular expression matching HTML tags:/< (. *) >.*<\/\1>|< (. *) \/>/
Matching a regular expression with a trailing space: (^\s*) | (\s*$) (Trim function like VBScript)
Regular expression matching an email address: \w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *
A regular expression that matches URL URLs: http://([\w-]+\.) +[\w-]+ (/[\w-/?%&=]*)?
Here is an example:
Use regular expressions to restrict the entry of text boxes in a Web page's form:
The regular expression limit can only be entered in Chinese: onkeyup= "value=value.replace (/[^\u4e00-\u9fa5]/g,") "Onbeforepaste=" Clipboarddata.setdata (' Text ', Clipboarddata.getdata (' text '). Replace (/[^\u4e00-\u9fa5]/g, ') "
1. Only full-width characters can be entered with regular expression restrictions: onkeyup= "Value=value.replace (/[^\uff00-\uffff]/g,") "Onbeforepaste=" Clipboarddata.setdata (' Text ', Clipboarddata.getdata (' text '). Replace (/[^\uff00-\uffff]/g, ') "
2. Only numbers can be entered with regular expression restrictions: onkeyup= "Value=value.replace (/[^\d]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ') "
3. Only numbers and English can be entered using regular expression restrictions: onkeyup= "Value=value.replace (/[\w]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ') "
//Erase image Toolbar
Or
<meta http-equiv= "Imagetoolbar" content= "no" >
No prompt shutdown
function Close ()
{
var ua=navigator.useragent
var ie=navigator.appname== "Microsoft Internet Explorer"? True:false
if (IE)
{
var ieversion=parsefloat (ua.substring (Ua.indexof ("MSIE") +5,ua.indexof (";", Ua.indexof ("MSIE")))
if (ieversion< 5.5)
{
var str = ' <object id=notipclose classid= ' clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11 ' > '
str = ' <param name= ' Command ' value= ' close ' ></object> ';
Document.body.insertAdjacentHTML ("BeforeEnd", str);
Document.all.noTipClose.Click ();
}
Else
{
Window.opener =null;
Window.close ();
}
}
Else
{
Window.close ()
}
} Get the absolute position of the control (1)
<script language= "JavaScript" >
function GetOffset (e)
{
var t=e.offsettop;
var l=e.offsetleft;
while (e=e.offsetparent)
{
T+=e.offsettop;
L+=e.offsetleft;
}
var rec = new Array (1);
Rec[0] = t;
REC[1] = l;
Return rec
}
</script>Get the absolute position of the control (2)
orect = Obj.getboundingclientrect ();
Orect.left
Orect. //Minimized, maximized, closed <object id=min classid= "Clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" >
<param name= "Command" value= "Minimize" ></object>
<object id=max classid= "Clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" >
<param name= "Command" value= "Maximize" ></object>
<object id=close classid= "Clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" >
<param name= "Command" value= "Close" ></OBJECT>
<input Type=button value= Minimize onclick=min. Click () >
<input Type=button value= maximize Onclick=max. Click () >
<input Type=button value= closes Onclick=close. Click () >
The cursor stops at the end of the text
<script language= "JavaScript" >
function cc ()
{
var e = event.srcelement;
var r =e.createtextrange ();
R.movestart (' character ', e.value.length);
R.collapse (TRUE);
R.select ();
}
</script>
<input type=text name=text1 value= "123" onfocus= "CC ()" > The effects of page entry and exit
Enter page <meta http-equiv= "Page-enter" content= "Revealtrans (duration=x, transition=y)" >
Launch page <meta http-equiv= "Page-exit" content= "Revealtrans (duration=x, transition=y)" >
This is some special effects when the page is loaded and paged out. Duration represents the duration, in seconds, of the effect. Transition said the
What kind of effect, the value is 1-23:
0 Rectangle Shrink
1 Rectangle Enlargement
2 round Shrink
3 Circular Enlargement
4 down to top refresh
5 Top to bottom refresh
6 Left to right refresh
7 Right to left flush
8 Vertical Blinds
9 Horizontal Blinds
10 Dislocation Horizontal Blinds
11 Misplaced Vertical Blinds
12 Point spread
13 or so to the middle of the refresh
14 Middle to left flush
15 Middle to bottom
16 up and down to the middle.
17 right down to top left
18 top right to bottom left
19 top left to bottom right
20 left down to top right
21 Cross Bar
22 Vertical Bar