11, web-making Dreamweaver (add: JS fragmented knowledge points && regular expressions)

Source: Internet
Author: User

JS Knowledge Point

the difference between the carriage return/R and the newline character/n:/R equals Enter, which is the difference between a paragraph and a paragraph.

/n is equivalent to Shift+enter, which is the distance between rows and rows, smaller than

Several window operation methods:

1. Get the current window size and print:

var height=window.innerheight; var width = window.innerwidth;document.write ("<br/>" + "height" +height+ "," + "width" +width);

2. Open the window, close the current window

window.open ("http://baidu.com"); Window.close ();

3. Move the current window to a location (x, y)

Window.moveto (200,200);

4. Change the size of the current window (width,height)

Window.resizeto (1100,1100);

5. Get the current page address

document.write (location. href);

6, "History" page forward (forward to the previous history, equivalent to "→"), back (back to the previous history, equivalent to "←")

<!-- use the. Back method setting in another Web page  - <  type= "button"  onClick= "A ()"= "point me forward"/>
function A ()    {        window.history.forward (); /* forward to the previous history */     }

*navigator Visitor's browser information

Alert: Warning Box confirm: Confirmation box prompt: Prompt box

Regular expression regexp:

Methods for establishing regular expressions:

var New REGEXP (/^[0-9]{17}[0-9| x]$/); /* REGEXP () The expressions inside the parentheses need to be defined by themselves: 1, [] There is only one element 2, () inside can write a word or expression 3, {} inside the number
4. ^: start with an element and write it in front of the element
5, $: End With an element, written behind the element * /

Cases:

1. Regular Expression Authentication ID:

  ID:  <  input  type  = "text"   ID   = "1"  />  
/* JavaScript Section */  var a= document.getElementById ("1"). Value;   var New REGEXP (/^[0-9]{17}[0-9| x]$/);   if (Patten.test (a))  {      alert ("enter correct");  }   Else   {      alert ("input error");  }

2. Regular Expression Verification mailbox:

 mailbox: <  input  type  = "text"   ID  = "2"  />  <  input  type  = "button"   value  = "Commit"   onclick  = "Mail ()"  /> 
function Mail () {    varnew RegExp (/^[0-9| a-z|_]{1,17}[@][0-9| a-z]{1,3}. (COM) $/)    var mail = document.getElementById ("2"). Value;     if (patten2.test (mail))      {          alert ("enter correct");      }     Else       {          alert ("input error");}      }

11, web-making Dreamweaver (add: JS fragmented knowledge points && regular expressions)

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.