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

Which attribute is introduced by HTML into the external javascript

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "HTML introduces the attributes of external javascript", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "which are the attributes of external javascript introduced by HTML?"

HTML introduces that the external javascript is the src attribute of the script tag, which specifies the URL; syntax of the external script file.

The operating environment of this tutorial: windows7 system, HTML5&&javascript1.8.5 version, Dell G3 computer.

HTML introduces an external javascript as the src attribute of the script tag.

Tags are used to define client script, such as JavaScript.

The script element can either contain script statements or point to an external script file through the src attribute.

Sometimes we need to run JavaScript on multiple pages of the site. Instead of writing the same script over and over again, just create a JavaScript in a separate file, save it with a .js suffix, and then reference the file using the src attribute in the tag.

Grammar

Value description URL

The URL of the external script. Possible values are:

Absolute URL-points to other sites (such as src= "www.example.com/example.js")

Relative URL-points to a file within the site (such as src= "/ scripts/example.js")

Example:

Output:

Description:

Once the tag uses the src attribute, it serves as an element that references an external file rather than editing a script inside the page. That is, using src indicates that the element is suitable for referencing an external Javascript file, and not for inserting a Javascript script into the page.

This indicates that code should not be inserted into tags that use the src attribute (and useless). This can lead to unpredictable results, and, at least in most browsers, it has no practical effect. If you add the following code to the example of this article:

[xss_clean] ("the content of this output comes from the Javascript of this file.")

It may properly parse the Javascript file referenced by the src attribute, but it may not execute any code that is edited directly within the tag. Obviously, many special properties (such as the attributes that its parts can only be used for external files) determine that it is no longer possible to execute the referenced external file normally while taking into account the content directly edited in it.

Thank you for your reading, the above is the content of "HTML introduces the attributes of external javascript". After the study of this article, I believe you have a deeper understanding of which is the attribute of external javascript introduced by HTML, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Internet Technology

Wechat

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

12
Report