161122. Example of BOM operation

Source: Internet
Author: User

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

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.