I developed an HTML page that uses jQuery and Ajax. I had the following lines in my <head>
tag:
<script language="javascript" type="application/javascript" src="script/jquery.js"></script>
<script language="javascript" type="application/javascript">
function someFunction() {
some code;
}
</script>
...
later - down in the body tag:
<a href="javascript:someFunction();">click here</a>
It worked perfectly in FF and Chrome, but threw an "Object Expected" in IE8 as soon as I clicked the link. Even with the Script Debugger on, it would not reach the first line of the function.
I tried switching to IE7 mode, or IE8 Compatability mode - to no avail.
I lucked out and found a question through Google where someone suggested changing the type
in the <script>
tag to "text/javascript"
and now it works in all 3 browsers.
My question is: what did I do wrong? Is "text/javascript"
better than "application/javascript"
, or is there a better (== more correct) solution to my issue?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…