admin管理员组

文章数量:1335847

Basically this is the question. Which is the difference between these two statements:

language

<script language="javascript" src="_js/calendar/calendar.js"></script>

text/javascript

<script type="text/javascript" src="_js/calendar/calendar.js"></script>

Basically this is the question. Which is the difference between these two statements:

language

<script language="javascript" src="_js/calendar/calendar.js"></script>

text/javascript

<script type="text/javascript" src="_js/calendar/calendar.js"></script>
Share Improve this question asked Sep 5, 2012 at 7:47 Daniel Ramirez-EscuderoDaniel Ramirez-Escudero 4,04713 gold badges46 silver badges81 bronze badges 2
  • nothing really. they both run & execute. – user1251600 Commented Oct 6, 2012 at 5:33
  • Just because they both currently run and execute doesn't mean they have no difference – Ben Taliadoros Commented Apr 25, 2013 at 9:03
Add a ment  | 

3 Answers 3

Reset to default 6

Per the HTML 4.01 Spec:

type: This attribute specifies the scripting language of the element's contents and overrides the default scripting language. The scripting language is specified as a content type (e.g., "text/javascript"). Authors must supply a value for this attribute. There is no default value for this attribute.

language: Deprecated. 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.

Language is generally used to indicate the Javascript version that your script requires. Browsers that support the language attribute won't load or run the script if it doesn't support it. About the only use would be if you had critical Javascript functions where you needed workarounds for older browsers.

The language = JavaScript suggests that the language formatting and error-checking is to be based on JavaScript standards. The type = text/javascript only suggests that the inner contents' formatting will be text, in JavaScript form.

But language = JavaScript is deprecated anyway, so don't worry.

Taking a look at W3 language should have been deprecated or removed :

<!ELEMENT SCRIPT - - %Script;          -- script statements -->
<!ATTLIST SCRIPT
  charset     %Charset;      #IMPLIED  -- char encoding of linked resource --
  type        %ContentType;  #REQUIRED -- content type of script language --
  src         %URI;          #IMPLIED  -- URI for an external script --
  defer       (defer)        #IMPLIED  -- UA may defer execution of script --
  >

本文标签: jquerydifference between typetextjavascript and languagejavascriptStack Overflow