Is the .js file ending a strict requirement for externally referenced JavaScript pages? I have not run into issues 开发者_如何学Cwith IE6,7,8 and FF3.5 in testing but wanted to confirm. I have an architecture limitation leading me to this question.
I didn't think so, but if it's giving you problems just add a query string ending in ".js" to your url...
<script src="/scripts/myscript.weirdextension?dummy=myscript.js"></script>
It's not required. I see plenty of ".php" files that are the source of script tags.
Provided that the file outputs with a mime-type of application/x-javascript
, there should be no problems.
A quick test shows that Google Chrome will allow for an incorrect mime-type, throwing a warning to the console. Maybe Internet Explorer is a little stricter.
You must specify 'type' property of 'script' tag or pass 'Content-type: application/x-javascript' header from the server. There are no restriction for filename.
精彩评论