Browser-related information
Browser information
Navigator.useragent//mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) applewebkit/537.36 (khtml, like Gecko) chrome/54.0.2840.71 safari/537.36
Operating system platform running the browser
Navigator.platform//Macintel
Browse Record History
Forward
History.forward ()
Back off
History.back ()
URL Information
Page Jump
The current page is recorded in the history of browsing history
Location.href = ' http://www.baidu.com '
The current page is not recorded in the history of browsing history
Location.replace (' http://www.baidu.com ')
Page Reload
Location.reload ()
Get information about the current URL
Assuming the current URL is http://192.168.31.194:8000/jquery/index.html?a=3&c=aa#b
Location.href//Full URL
Location.hostname//192.168.31.194
Location.host//192.168.31.194:8000
Location.port//8000
Location.protocol//http:
Location.search//? A=3&C=AA
Location.hash//#b
Location.pathname///jquery/index.html
Global objects
Information pop-up box
Alert (' You're handsome! ‘)
Confirm Popup Box
var isReady = confirm (' Ready to come? ')
if (IsReady) {
} else {
}
Enter the information pop-up box
var name = prompt (' Please enter your name ')
Console.log (name)
Open a new window
Open (' http://baidu.com ')
Change the URL of a window
Open (' http://baidu.com ', ' a ')
The address of open (' http://youku.com ', ' a ')//above window will change from Baidu to Youku
Executed after a period of time
1 seconds to execute.
SetTimeout (function () {
Dosth
}, 1000)
Execute every once in a while
var i = 1
Executes every 1 seconds after
var runId = setinterval (function () {
Console.log (i++)
if (I >= 10) {
Clearinterval (RUNID)//Stop execution
}
}, 1000)
The screen is executed every time it refreshes
It is common to render some UI.
var Targetel = Document.queryselector ('. Tar ')
var res
var isstop
var runId = requestanimationframe (function () {
Targetel.text (RES)
if (isstop) {
Cancelanimationframe (RUNID)
}
})
Output information in the console
Console.log (' Log message ')
Console.warn (' warning message ')
Console.info (' General Information ')
Console.error (' Error message ')
Console.log (' 1+2 =%d ', 3)
var person = {name: ' Joel ', Gender: ' Man '}
Console.log (' Name:%s, Gender:%s ', Person.name, Person.gender)
161122. Example of BOM operation