0
  <script language="JavaScript1.2" ...
  <script language="JavaScript"  ...

Would those declarations make the JavaScript execution differ?

4

2 回答 2

1

The language attribute is obsolete, browsers should only respect the type="" attribute.

On a historical note, the DOM API was (and ostensibly, still is) designed for many different languages and the W3C didn't endorse JavaScript in particular. Browsers have, at one point, supported:

  • JavaScript/ECMAScript
  • VBScript (Internet Explorer)
  • JScript (Microsoft's extensions to ECMAScript)
  • tcl (referenced by the HTML4.01 specification)
  • Rexx (IBM WebExplorer on OS/2)
  • Python (supported by Mosaic for a brief period)

So the idea was that different browsers were free to support whatever language they wanted, and it might be platform-specific if they executed scripts using some operating-system built-in language instead of it being embedded in the browser's own code-base (like how JScript/VBScript in Internet Explorer came from Windows' Active Scripting feature, it wasn't built-in to IE (until IE9), or tcl on Unix)

So on Internet Explorer I understand that IE would use the language="" attribute to look-up other Active Scripting languages if installed - so if you had a third-party script engine installed, like "ActivePerl" or even Fortran then that would also work in a <script> element in HTML, which is kinda crazy.

To answer your question directly (what possible values are there), the answer is "no-one knows": the attribute was deprecated back in 1998 in the HTML4.01 specification precisely because there was no standardised list of values for the language="" attribute:

https://www.w3.org/TR/html4/interact/scripts.html#adef-language

language This attribute specifies the scripting language of the contents of this element. Its value is an identifier for the language, but since these identifiers are not standard, this attribute has been deprecated in favor of type.

于 2018-06-13T22:21:46.780 回答
0

As with most simple questions like this, a good route to go is simply to preface your search with MDN (Mozilla Developers Network) and look at the results.

Googling: mdn script language

This gives the MDN page <script>: The Script element, and more specifically:

Deprecated attributes

language

Like the type attribute, this attribute identifies the scripting language in use. Unlike the type attribute, however, this attribute’s possible values were never standardized. The type attribute should be used instead.

于 2018-06-13T22:21:59.303 回答