...

View Full Version : calling up a javascript inside a javascript



webguzs
06-16-2004, 03:01 PM
I have a script that detects browsers. It works well, however I want it to detect the browser then based on the browser detected process another javascript.

here is the working syntax:

<SCRIPT LANGUAGE="JavaScript"><!--
if (navigator.appName == 'Netscape')
location.href = 'netscape.html';
else {
if (navigator.appName == 'Microsoft Internet Explorer')
location.href = 'explorer.html';
else if (navigator.appName == '*')
location.href = 'other.html';
}
//--></script>

This works to send to a web page but the location.href command doesnt work to call up a function like

<script type="text/javascript" language="JavaScript1.2" src="script.js"></script>

can someone please help?

sage45
06-16-2004, 10:02 PM
Try:


location.href = 'script.js';

-sage-

glenngv
06-17-2004, 04:22 AM
That will open the js file.

Maybe this is what you want.


var oScript = document.createElement("script");
oScript.setAttribute("type", "text/javascript");
oScript.setAttribute("src", "script.js");
document.getElementsByTagName('head')[0].appendChild(oScript);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum