One question was asked:
The code copy is as follows:
<script language = "JavaScript">
<script type="text/javascript">
<script>
What is the difference between using these three tags?
Although I have been using it, I haven't figured it out carefully. Here I will explain it in detail.
Check some information, mainly because of browser support issues. Both the type and language properties can be used to specify the type of scripts in the <script> tag. The language attribute has been criticized in the HTML and XHTML standards, which advocate the use of type attributes. Unfortunately, the values of these two properties are different.
You may occasionally see the language value VBScript (text/vbscript for type), indicating that the script code contained is written in Microsoft's Visual Basic Script.
With JavaScript, you can also use the value "JavaScript 1.1" of the language, indicating that the included script statements can only be processed by Netscape 3.0 or later. Netscape 2.0 only supports JavaScript 1.0 and cannot handle scripts marked "JavaScript 1.1".
To ensure that scripting programs can execute normally, unless you deliberately use the VBScript and Script Encoder mechanisms that are only supported by IE, the "type" attribute of the SCRIPT tag should be set to "javascript", and do not set the "Languange" attribute that has been abandoned.
Each browser supports both the "type" and "language" attributes themselves, but the script language type recognition and support are different for the settings:
When "type" and "language" exist at the same time, all browsers preferentially recognize script types within the "type" attribute;
Among them, the IE browser actually supports JScript and VBScript script language labeling and Script Encoder encryption;
Firefox Chrome Safari Opera has inconsistent tolerance for the specific identification of "type" attribute values. Compared with Chrome Safari, the verification of the correctness of attribute values is more relaxed, and Firefox is the most stringent;
In the comparison of tolerance for the recognition of "Language" attribute value, Chrome Safari is still the loosest among all browsers, IE is the strictest, and Firefox is the same as Opera;
In Language Encode comparison, only IE supports JScript.Encoder and VBScript.Encoder type settings, Firefox Chrome Safari does not support it, and in Opera, this property value is fixed to the default Javascript scripting language only has an output value.
The code copy is as follows:
<script language="javascript">
function a() {
b = "a";
}
a();
alert(b);
</script>
There is a problem with variables, even if you declare a variable in a function as above, it will become a global variable.
There will be a problem if you declare it with var.
The code copy is as follows:
<script language="javascript">
function a() {
var b = "a";
delete b;
alert(b);
}
a();
</script>
The result will still pop up.
To ensure that scripting programs can execute normally, unless you deliberately use the VBScript and Script Encoder mechanisms that are only supported by IE, the "type" attribute of the SCRIPT tag should be set to "javascript", and do not set the "Languange" attribute that has been abandoned.