On JavaScript grammar and timing function

Source: Internet
Author: User
Tags object model

Beginners may misunderstand the JavaScript timer, think they are threads, in fact, JavaScript is running in a single thread, and the timer is only scheduled to be executed at some time in the future, and the specific execution time is not guaranteed, because in the page life cycle, There may be other code in the process of controlling javascript at different times.

First, JavaScript basic syntax.

(i) Data type and variable type. Integer, Decimal, Layout, string, date time, array cast: parseint () parsefloat () isNaN ()

(ii) array var array name = new Array ([length]); "Counterfeit" array a.length-length a[subscript] = value. a[Subscript]

(iii) function

Copy code code as follows:

function functions name (formal parameter)



function Showstr (a)



Second, Dom operation

Dom-document object Model Document objects. Tree

Linear model, tree-like model, mesh model








A,img,table,ul,ol .....


The verb of noun behavior--object characteristic of object

(i) window 1.alert () Window.alert ();

2.[var a =]window.confirm ("Can you run over the leopard?)" Prompt (); --not used, don't remember, enter

3.open (); Open ("Address", "_blank/_self", "features of the new Window"); [var a =]window.open ("http://jb51.net"); Open the page in a new window and return to the new window. A is also a variable of type window. Detailed translation is required.

4.close (); Window.close ();

5.setTimeout ("code", number of milliseconds) after the specified number of milliseconds, execute the code once.



1 2 3 4 5 6 7 8 9 10 11 <script language= "JavaScript" > Function showTime () {var date = new Date (); document.getElementById ("hh"). innerhtm L = date;   Window.settimeout ("ShowTime ()", 1000); } window.settimeout ("ShowTime ()", 1000); </script>


Do a page in 5 seconds after the first page of the question


1 2 3 4 5 6 7 8 9 10 11 12 13 14-15 16 <script language= "JavaScript" > var A;   function Openad () {a = window.open ("http://hovertree.com", "_blank", "width=200" height=200 toolbar=no top=0 left=0); Window.settimeout ("Closead ()", 5000);   function Closead () {a.close ();} window.settimeout ("Openad ()", 5000); </script>

The above mentioned is the entire content of this article, I hope you can enjoy.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.