JavaScript——五

onload: at load time

Because the page code is executed from top to bottom, so some of our operations on the first page content to load a web content after the implementation of the contents of script, this time if we can not onload written on the back of these contents, but with load is not the same

But the load is flawed, is to wait until the page load in all things, including audio and video, will be performed in the content load, this time will make it slow!

onunload: In your off page when the page disappears, so it will not show up, but the equivalent of unloading and reloading the web page at the time of refresh, so you can look out at this time, so this function is mainly to write some pages after the close cleanup

settimeout:

There are two parameters, the first is a function, you can write an anonymous function, and the second is the time, in milliseconds, will execute this anonymous function in the event of time to reach

Return Value: The return value of this function is a number, you can find this number by the timer

Clear Timer function: cleartimeout

Another timer (interval of time to do a thing, is to what a time to do the things (just do a), we can do this several times): setInterval: a Like its parameters and on, but also the two parameters

Clear this timer, the function's return value is an identity

Countdown Case:

January 1, 1970 0,0,0

 

Math.floor (): rounded down

new Date (year - month - day - when - minutes and seconds) during which the default is 0 minutes and seconds do not write

But this timer is to a certain time before the execution, there will be some lack in between all pages loaded into the timed

Solution: to setInterval function in the anonymous function a name, and then to call it directly

 

But there is also no problem if a number is not enough in front of two he will not automatically fill 0, so we have to improve

The first solution: for obj.hour / day and the like into a string (.toString ())

 

The second: determining whether the figure of less than 10

The basic types are worth passing on to the heap memory in another variable replication again, and this reference type is a memory address to a variable, but their address is the same, as his name (reference)

 Exercise:

 Exercise: Click the Start box to make the right moves a certain distance (little by little movement)

location: you can print it out in order to see its members

location.href = "": is the web address bar, that URL

 location.search is to get some of the data page URL "? .." back

location.hash get a web page anchor 

E.g:

 www.baidu,com?name=123&age=2#123

则location.search=?name=123&age=2

location.hash=#123

Forward and backward on the analog page

User.Agent put their information is also passed to the server

JavaScript code is single-threaded execution

 He is the first thing executed outside of the event, when faced with an event, the event will be placed inside the queue, then wait until after all execution will be performed over the contents of the queue

Drag effects:

onmousemove: Press the mouse when not bounce

onmousedown: mouse down time

 onmouseup: Release the mouse button

psition: fixed scroll bar is also all right, otherwise pick up some error occurs

The plus and minus 256 to 140 is because we have this window to set up magin: left and top, so there will be some errors

_.offsetWidth: The width of the object

_.offsetHeight the height of the object

 The size of the entire page: Window.innerWiddth / innerHeight expressed

 

 

Guess you like

Origin www.cnblogs.com/kongbursi-2292702937/p/10783482.html