1. BOM Introduction1. JavaScript consists of three parts
2.Window object
Common methods:
open Open the specified window <script> function f1() { //This is not a CSS style, the size of the open window can be adjusted open('test.html', 'user', 'width=500px,height=500px') } </script> </head> <body> <button onclick="f1()">Open a new window</button> </body>
<script> function f1() { //This is not a CSS style, the size of the open window can be adjusted open('test.html', 'user', 'width=500px,height=500px') } function f2() { setTimeout(f1, 2000) } </script> </head> <body> <button onclick="f2()">One-time timer</button> </body>
Turn off a one-shot timer, within the time frame that was not executed ```javascript <script> function f1() { //This is not a CSS style, the size of the open window can be adjusted open('test.html', 'user', 'width=500px,height=500px') } </script> </head> <body> <button onclick="f1()">Open a new window</button> </body>
<script> function f1() { //This is not a CSS style, the size of the open window can be adjusted open('test.html', 'user', 'width=500px,height=500px') } var timer function f2() { timer = setTimeout(f1, 2000) } function f3(){ clearTimerout(timer) } </script> </head> <body> <button onclick="f2()">One-time timer</button> <button onclick="f3()">Turn off the one-shot timer</button> </body>
Move to the specified position <script> function f1() { scrollTo(0, 100) //Unit is px } </script> Common events
Note: Since the window object is the top-level object of the BOM structure, the window can be omitted when calling window properties and methods. <script> //Execute after clicking the window window.onclick = function() { console.log(111) } </script> 3.location objectCommon properties href sets or returns the URL in the address bar Common method reload() reloads the current page <script> function getUrl() { //Get the URL in the address bar console.log(location.href) //Set the URL in the address bar to redirect the page //location = 'https://www.baidu.com' location.href = 'https://www.baidu.com' //Reload the page location.reload(); } </script> </head> <body> <button onclick="getUrl()">Get url</button> </body> 4.History Object
<script> function goBack() { history.back() } function goforward() { history.forward() } function goGo() { history.go(1) //Go forward one } </script> </head> <body> <button onclick="goBack()">Back</button> <button onclick="goforward()">Go forward</button> </body> SummarizeThis article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: Recommend a cool interactive website made by a front-end engineer
>>: MySQL database operations and data types
1. Log in to mysql: mysql -u root -h 127.0.0.1 -p...
It is very convenient to configure virtual host v...
Preface As we all know, everything in Linux is a ...
What is Redis Cluster Redis cluster is a distribu...
No matter you are installing Windows or Linux ope...
Preface If you are like me, as a hard-working Jav...
Node.js solves the problem of Chinese garbled cha...
1. Warm and gentle Related address: http://www.web...
The meaning of key_len In MySQL, you can use expl...
Table of contents Simple CASEWHEN function: This ...
Table of contents Solution 1: Copy the transfer c...
Table of contents 1. MySQL replication related co...
Optimizing and refining information is always the ...
Table of contents Preface start Basic layout Data...
Table of contents Is real-time update required? M...