type="application/javascript"

來源:互聯網
上載者:User

標籤:

    type="application/javascript"html script 標籤中 type有如下這些值,請問分別是什麼意思,在什麼情況下使用?
  • type="text/javascript" 
  • type="application/javascript" 
  • type="application/x-javascript" 
這3個有什麼區別嗎 ? 

 

 

  1. The traditional MIME type forJavaScript programs is "text/javascript".Another type that has been used is "application/x-javascript"(the "x" prefix indicates that it is an experimental, nonstandard type). RFC 4329 standardized the "text/javascript" type because it is in common use.However, because JavaScript programs are not really text documents, it marks this type as obsolete and recommends "application/javascript"(without the "x-") instead.At the time of this writing,"application/javascript" is not well supported, however.That might be the reason why "application/x-javascript" is used by a lot of webpages.
 

 

大致意思是:傳統的javascript程式的MIME類型是“text/javascript”,其他使用的還有"application/x-javascript"(x首碼表示這是實驗性的,不是標準的類型),RFC4329規定了“text/javascript”類型,因為它普遍被使用。然而,javascript程式並不是真正的文字檔,這就表示這個類型已經意味著過時了,而推薦使用"application/javascript"(去除x首碼)。然而,在寫程式的時候,"application/javascript"沒有很好的支援。這也就是"application/x-javascript"不被使用在很多網頁中的原因。

 

您是否很疑惑為什麼我們沒有在<script>標籤中使用 type="text/javascript"? 

在 HTML5 中,不必那樣做了。JavaScript 是 HTML5 以及所有現代瀏覽器中的預設指令碼語言!

 



 



type="application/javascript"

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.