IT.COM

Linking to External JS files - Did you do it right?

NameSilo
Watch
Impact
1
Alright, some of you may have linked to an external file like this before:

<SCRIPT LANGUAGE="JavaScript" SRC="mything.js"></SCRIPT>

That's right, right? WRONG!

This will work on about 5% of the browser - I'm sure that's not what you want!

I read an artical a long time ago on why the following worked but I forget now :p :

<SCRIPT LANGUAGE="javascript1.2" TYPE="text/javascript">
<!--
document.writeln("<SCR" + "IPT LANGUAGE='javascript1.2' SRC=myfile.js' TYPE='text/javascript'></SC" + "RIPT>")
//-->
</SCRIPT>


That code will work with almost anything that supports javascript - even ASP pages!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back