application/javascript in IE

  • Avinash
  • 2
  • May 25, 2011
  • Tutorial

Recently I was wrinting a very basic javascript code. Code is as below:

<script type="text/javascript">
// <![CDATA[
// ]]>

Isn’t this really simple? After just writing this I have start testing of this.

FireFox -> Working
Opera -> Working
Chrome -> Working
Safari -> Working
IE -> Not Working

I have done lots of searching over net for number of hours. But not found even a ray of hope for this problem.

Finally i have written the whole code again, and it starts working in all browser. Below is the new code:

<script type="text/javascript">
// <![CDATA[
// ]]>

Here you will not find any change in the javascript code but please notice that type attribute in script declaration. Those are text/javascript and application/javascript.

I don’t know whats the difference between these two but when you place application/javascript in your type attribute then Internet Explorer will completely ignore the script code.

So finally text/javascript have solved my problem, But yes if you know the Difference between text/javascript and application/javascript then please share to all by commenting here. Also you can explain the case in which can we can use particular. Looking forward for your response.



Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by:

  • Thomas Schmidt

    The difference is simple: application/javascript is the correct mime type while text/javascript never existed officially.

    Microsoft know that and shits on it. Do you really want to write defective code to make some stupid “developers” happy? I have enough visitors without that crap.

  • Hossein Baghayi

    The both codes are the same, even the value of the type attribute,
    Have a look at it, please :)