BOM model browser object model (browser object model), the browser itself can be operated through some objects built into the browser.
DOM is used to operate the page, and BOM is used to operate the browser itself.
BOM is not standardized, but most browsers support the following objects
1. Window object: represents the entire window
(1) open Method: (name, characteristics, height and width, toolbar, scroll bar)
(2) setTimeout method: setTimeout(fn, milliseconds); //The first parameter must be a function name (no brackets allowed) )
<html> <head> <script> function f1(){ //win指向了新打开的窗口 var win = window.open('day05_03','wi_1', 'width=400,height=400'); setTimeout(function(){ win.close(); }, 5000); } </script> </head> <body> <input type="button" value="click me" onclick="f1();"/> </body> </html>
(3) setInterval method
var taskId = setInterval(fn, milliseconds); //Execute a function after the specified time interval
(4) clearInterval method
clearInterval(taskId); //Cancel the task of setInterval
<html> <head> <style> #d1{ width:80px; height:80px; background-color:blue; position:relative; } </style> <script src="myjs.js"></script> <script> function f2(){ var v1 = parseInt($('d1').style.left); $('d1').style.left = v1 + 50 + 'px'; } function f1(){ var taskId = setInterval(f2, 500); setTimeout(function(){ clearInterval(taskId); },5000) } </script> </head> <body> <div id="d1" style="left:10px;"></div> <input type="button" value="click me" onclick="f1();"/> </body> </html>
(5) alert() method Pop up a warning dialog box
(6) confirm() method
var flag = confirm(string); //string is the prompt message, flag returns true or false
(7) prompt method
var info = prompt(string)
<html> <head> <script> function f3(){ var flag = confirm('你喜欢钱吗?'); alert(flag); } function f4(){ var info = prompt('请输入手机号'); alert('你输入的手机号是:' + info); } </script> </head> <body> <input type="button" value="click me" onclick="f4();"/> </body> </html>
2. Document object: represents the root of the entire document
getElementById(id);
createElement(tagName);
write(string); Output relevant information at the specified location
<html> <!-- document对象 --> <head></head> <body style="font-size:30px;"> 开始输出helloword<br/> <script> for(i=0; i<100; i++){ document.write('hello world<br/>'); } </script> </body> </html>
3, Location object: encapsulated Related information of the browser address bar
href attribute: Specify the page to be loaded
reload method: Reload the current page, which is equivalent to refreshing
<html> <!-- location对象 --> <head></head> <body> <input type="button" value="跳转到另外一个页面" onclick="location.href = 'day05_04.html';"/><br/> <input type="button" value="刷新当前页面" onclick="location.reload();"/> </body> </html>
4, History object: Encapsulates the browser has visited Related information about the past page
back(): go back
forward(): go forward
go (parameter): positive number goes forward, negative number goes back
<html> <!-- history对象 --> <head></head> <body> <input type="button" value="点这里后退" onclick="history.back();"/> <input type="button" value="点这里前进" onclick="history.forward();"/> <input type="button" value="点这儿后退" onclick="history.go(-1);"/> </body> </html>
5, Navigator object : Encapsulates the relevant information of the browser, (such as: type, version)
<html> <!--navigator对象--> <head></head> <body> 现在访问的浏览器的相关信息如下:<br/> <script> var info; //for in循环:主要用于遍历对象 for(propName in navigator){ //propName是任意变量 // 将navigator对象的属性名保存到propName变量里 info += propName + ';' +navigator[propName] + '<br/>'; } document.write(info); //在当前页面输出 </script> </body> </html>
<html> <!--检测浏览器类型--> <head> <script> function f1(){ if((navigator.userAgent).indexOf('Firefox')>0){ alert("当前浏览器是Firefox"); }else if(navigator.userAgent.indexOf('MSIE')>0){ alert("当前浏览器是IE"); }else{ alert("其他浏览器"); } } </script> </head> <body> <input type="button" value="获得当前浏览器的类型" onclick="f1();"/> </body> </html>
6, Screen object: the relevant information of the screen where the browser is located
<html> <head> <script> function f2(){ alert(screen.width + ' ' + screen.height); } </script> </head> <body> <input type="button" value="获得screen相关信息" onclick="f2();"/> </body> </html>
The above is the content of Xiaoqiang’s HTML5 mobile development road (32) - JavaScript review 7. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools