Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What interprets and executes javascript scripts

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will introduce in detail "javascript script is by what interpretation and execution", the content steps are clear and detailed, the details are properly handled, and Xiaobian will update different knowledge points every day, I hope this article "javascript script is by what interpretation and execution" can give you unexpected gains, please follow Xiaobian's thinking slowly, the specific content is as follows, together to harvest new knowledge bar.

JavaScript scripts are interpreted and executed by browsers, and javascript scripts are executed: 1. Browsers execute scripts when opening pages;2. Use onLoad events to execute scripts;3. Use user events to execute scripts.

Operating environment: Windows 7 system, javascript version 1.8.5, DELL G3 computer

Javascript scripts are interpreted and executed by browsers.

When will javascript scripts be executed?

Javascript scripts can be embedded anywhere in html, but when is it invoked? When the browser opens the HTML file, it will directly run a script that is not a declaration function or call a script function through an event. The following analysis of these cases.

1. Browser executes script when opening page

When a browser opens an HTML file, it interprets the entire file from scratch, including html tags and scripts. If there are statements in the script that can be executed directly, they will be interpreted and executed as soon as they are encountered. There are two main situations:

1). This alert triggers the execution of functions like this.

demo alert("dare you click me once again");

2). The js function is automatically invoked as the browser loads (not triggered by user clicks, etc.)

2. Executing scripts with onLoad events (equivalent to listening for ** to occur and then executing)

The onLoad event occurs when a page is opened in a browser. This method is often used to display messages to the user while a page is open.

The following example demonstrates the onLoad event of the tag:

demo //insert javascript code here. function display() { alert("dare you click me once again") }

3. Executing scripts with user events

Users often use the mouse and keyboard to perform some operations when using the browser. Moving the mouse proportionally, clicking links or buttons, these operations will generate corresponding events. We can use these events to invoke script functions.

The following example uses a button click event to invoke the display() function.

demo //insert javascript code here. function display(){ alert("you click me ,it is so pain") }

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report