Attributo type script

Definizione e uso

type Imposta o restituisce il tipo di script dell'attributo Attributo type del valore.

L'attributo type definisce il tipo MIME dello script.

L'attributo type identifica il contenuto tra i tag <script> e </script>.

Il tipo MIME è composto da due parti: un tipo di media e un sottotipo. Per JavaScript, il tipo MIME è "text/javascript".

Nota:In HTML5, non è più necessario l'attributo type. Il valore predefinito è "text/javascript".

Vedi anche:

Manuale HTML:Proprietà type dell'etichetta <script> HTML

Manuale HTML:Etichetta <script> HTML

Esempio

Ottieni il tipo MIME dello script:

var x = document.getElementById("myScript").type

Prova tu stesso

Sintassi

Restituisce l'attributo type:

scriptObject.type

Imposta l'attributo type:

scriptObject.type = MIME_type

Valore dell'attributo

Valore Descrizione
MIME_type

Definisce il tipo MIME dello script.

Valori comuni:

  • text/javascript(predefinito)
  • text/ecmascript
  • application/ecmascript
  • application/javascript

Vedere Tipi MIME IANA, per ottenere l'elenco completo dei tipi MIME standard.

Dettagli tecnici

Valore di ritorno: Valore di stringa che rappresenta il tipo MIME dello script.

Supporto browser

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supporto Supporto Supporto Supporto Supporto