JavaScript Advanced Programming Application

Source: Internet
Author: User

One//various sizes (size)

s + = "\ r \ n page Visible area width:" + document.body.clientWidth;
s + = "\ r \ n page visible Area High:" + document.body.clientHeight;
s + = "\ r \ n page visible Area High:" + Document.body.offsetWeight + "(including edge width)";
s + = "\ r \ n page visible Area High:" + Document.body.offsetHeight + "(including edge width)";
s + = "\ r \ n Full text width:" + document.body.scrollWidth;
s + = "\ r \ n Full text High:" + document.body.scrollHeight;
s + = "\ r \ n page is rolled High:" + document.body.scrollTop;
s + = "\ r \ n page is rolled away left:" + document.body.scrollLeft;
s + = "\ r \ n Web page body part:" + window.screentop;
s + = "\ r \ n Page body part left:" + window.screenleft;
s + = "\ r \ n Screen resolution High:" + window.screen.height;
s + = "\ r \ n Screen resolution width:" + window.screen.width;
s + = "\ r \ n screen available work area height:" + window.screen.availHeight;
s + = "\ r \ n screen available work area width:" + window.screen.availWidth;
Filter numbers

Special purpose







Do not cache



Regular match

Regular expressions that match Chinese characters: [\U4E00-\U9FA5]
Match double-byte characters (including kanji): [\x00-\xff]
Regular expression that matches a blank line: \n[\s|]\ r
Regular expression matching HTML markup:/< (. *);.
<\/\1>|< (. *) \/>/
Regular expression matching the leading and trailing spaces: (\s)| (\s$) (Trim function like VBScript)
Regular expression matching email address: \w+ ([-+.] \w+)@\w+ ([-.] \w+). \w+ ([-.] \w+)
Regular expression matching URL URL:/http ([\w-]+.) +[\w-]+ (/[\w-./?%&=]
)?
Here is an example:
Use regular expressions to restrict the entry of text boxes in Web Forms:
Use regular expression restrictions to enter only Chinese: onkeyup= "value=value.replace (/[\u4e00-\u9fa5]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ' , Clipboarddata.getdata (' text '). Replace (/[\u4e00-\u9fa5]/g, ')) "
1. Restrict input of full-width characters with regular expressions: onkeyup= "Value=value.replace (/[\uff00-\uffff]/g,") "Onbeforepaste=" Clipboarddata.setdata (' Text ', Clipboarddata.getdata (' text '). Replace (/[\uff00-\uffff]/g, ')) "
2. Use regular expression restrictions to enter only numbers: onkeyup= "Value=value.replace (/[\d]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[\d]/g, ')) "
3. Use regular expression restrictions to enter only numbers and English: onkeyup= "Value=value.replace (/[\w]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ')) "

Remove Image Toolbar


Or


Silent shutdown

function Close ()
{
var ua=navigator.useragent
var ie=navigator.appname== "Microsoft Internet Explorer"? True:false
if (IE)
{

   

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

}

   

{

    window.opener =null;     window.close();    

Else
{
Window.close ()

}

Get control absolute Position (1)

Get the absolute position of the control (2)

Orect = Obj.getboundingclientrect ();
Orect.left
Orect.

Minimize, Maximize, close






The cursor stops at the end of the text

Effects of page entry and exit

Go to Page
Launch page
Here are some special effects when the page is loaded and paged out. Duration indicates the duration of the effect, in seconds. Transition means that the
Which effect to use, the value is 1-23:
0 Rectangle reduction
1 Rectangle Enlargement
2 Round Zoom Out
3 Circular Enlargement
4 down to top refresh
5 Top to bottom refresh
6 Left to right refresh
7 right-to-left refresh
8 Vertical Blinds
9 Horizontal Blinds
10 Dislocation Horizontal Blinds
11 Dislocation Vertical Blinds
12-point diffusion
13 or so to the middle refresh
14 Middle to left and right refresh
15 middle to upper and lower
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 lower left to top right
21 Horizontal Bar
22 Vertical Bar
23

Whether the page was retrieved
There are some of the following property values:
The property value is "All": The file will be retrieved and the link on the page can be queried;
The property value is "None": The file is not retrieved and the link on the page is not queried;
The property value is "index": The file will be retrieved;
The property value is "Follow": the link on the query page;
The property value is "Noindex": The file is not retrieved but can be queried for links;
The property value is "nofollow":

Print page out

Page1

Page2

Set up print

Classid= "clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
Codebase= "Http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360"








Specific user manual, more information, click here

Bring your own print preview
WEBBROWSER.EXECWB (*) Open
WEB.EXECWB (2,1) Close all IE windows now and open a new window
WEB.EXECWB (4,1) Save Web page
WEB.EXECWB (6,1) printing
WEB.EXECWB (7,1) Print preview
WEB.EXECWB (8,1) print Page Setup
WEB.EXECWB (10,1) view page Properties
WEB.EXECWB (15,1) seems to be withdrawn, pending confirmation.
WEB.EXECWB (17,1) Select all
WEB.EXECWB (22,1) Refresh
WEB.EXECWB (45,1) Close the form without prompting





Remove header and footer when printing



Browser validation

function Checkbrowser ()
{

this.ver=navigator.appVersion  this.dom=document.getElementById?1:0  this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;  this.ie4=(document.all && !this.dom)?1:0;  this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;  this.ns4=(document.layers && !this.dom)?1:0;  this.mac=(this.ver.indexOf(‘Mac‘) > -1) ?1:0;  this.ope=(navigator.userAgent.indexOf(‘Opera‘)>-1);  this.ie=(this.ie6 || this.ie5 || this.ie4)  this.ns=(this.ns4 || this.ns5)  this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns5 || this.ns4 || this.mac || this.ope)  this.nbw=(!this.bw)  

}

Calculate content width and height



Sdf

modeless Cue box function Modelessalert (MSG)
{

}

Shielded buttons


Shield right mouse button, CTRL + N, SHIFT+F10, Alt+f4, F11, F5 refresh, backspace key



Shield right mouse button, CTRL + N, SHIFT+F10, Alt+f4, F11, F5 refresh, backspace key

Shielded printing

Move the layer, drag

1.meizz

    1. Wlecome

Document status change

Text boxes that are not changed after refreshing







Accessing the Clipboard

Event.dataTransfer.setData ("URL", OIMAGE.SRC);
Simageurl = Event.dataTransfer.getData ("URL")
(2) General access
Window.clipboardData.setData ("Text", Osource.innertext);
Window.clipboardData.getData ("Text");

Manipulating cookies

function Setcookie (sName, svalue)
{
Document.cookie = sName + "=" + Escape (svalue) + ";";
}
function GetCookie (sName)
{
var acookie = Document.cookie.split (";");
for (var i=0; i < acookie.length; i++)
{

var acrumb = acookie.split ("=");
if (SName = = Acrumb[0])
Return unescape (acrumb[1]);
}

}
function Delcookie (sName)
{
Document.cookie = sName + "=" + Escape (svalue) + "; Expires=fri, to Dec 1999 23:59:59 GMT; ";
}

settimeout Adding parameters

Custom Apply,call

Function.prototype.apply = function (obj, Argu) {
if (obj) obj.constructor.prototype. caller = this;
var argus = new Array ();
for (var i=0;i argus = "argu[" + i + "]";
var R;
Eval ("R =" + (obj?) ("obj.
Caller ("+ Argus.join (", ") +"); "): (" This ("+ Argus.join (", ") +"); ")));
return R;
};
Function.prototype.call = function (obj) {
var Argu = new Array ();
for (var i=1;i argu[i-1] = arguments;
return this.apply (obj, Argu);
};

Download file

function Downurl (Strremoteurl,strlocalurl)
{
Try
{
var xmlhttp=new activexobject ("Microsoft.XMLHTTP");
Xmlhttp.open ("Get", Strremoteurl,false);
Xmlhttp.send ();
var adodbstream=new activexobject ("ADODB. Stream ");
Adodbstream.type=1;//1=adtypebinary
Adodbstream.open ();
Adodbstream.write (Xmlhttp.responsebody);
Adodbstream.savetofile (strlocalurl,2);
Adodbstream.close ();
Adodbstream=null;
Xmlhttp=null;

}
catch (E)
{
Window.confirm ("Error downloading URL!");
}
Window.confirm ("Download done.");
}

Verify that the connection is valid

function GetXML (URL)
{
var xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP");
xmlHTTP. Open ("GET", URL, false);
Try
{
xmlHTTP. Send ();
}
catch (e) {}
Finally
{
var result = Xmlhttp.responsetext;
if (result)
{

if(xmlhttp.Status==200) {  return(true); } else  {  

}
Else
{

}
}
}

Post instead of form

ReadyState is the progress of the XMLHTTP return data, 0 = loaded, 1 = uninitialized, 2 = loaded, 3 = running, 4 = complete
End

JavaScript Advanced Programming Application

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.