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
Data is the core asset of an enterprise and one o...
1. addtime() Add the specified number of seconds ...
1. Referential Integrity Referential integrity re...
1. Installation process MySQL version: 5.7.18 1. ...
Table of contents 1. Ant Design Vue 1. Official w...
Recently, I learned about the Vue project and cam...
First, I will give you the VMware 14 activation c...
Table of contents Preface design accomplish summa...
ssh-secure shell, provides secure remote login. W...
React project building can be very simple, but if...
User namespace is a new namespace added in Linux ...
I have recently studied the hollowing effect. bac...
Table of contents Overview 1. Download via URL 2....
0 Differences between icons and images Icons are ...
It has been a long time since the last update of ...