Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

short question on attaching js-files

Status
Not open for further replies.

JeroenB

Programmer
Apr 8, 2001
93
BE
Hi,

I have 'attached' a *.js-file to my html page;
now I want that this js-file is only read, when the browser is IE...

so what should I add or change to
<script language=&quot;JavaScript&quot; src=&quot;test.js&quot;>
</script>

Thanks in advance
JeroenB
 
i guess there is no way to disable loading it if the browser is not netscape, but inside the function that you attache you may check for IE browser and exit the function in case it's some other browser. You need server-side programming (e.g. with ASP or PHP) to disable loading of some parts of the page depending on certain conditions (i.e. like in your case, type of browser). I hpoe it helps.

---
---
 
I have successfully used the following technique to make sure an external script is only loaded if the browser is IE:

Code:
<script language=&quot;javascript&quot;>
if (navigator.appName.indexOf(&quot;Microsoft&quot;) != -1) document.write(&quot;<script language='javascript' src='myscript.js'></script>&quot;);
</script>

Hope this helps!

Petey

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top