View Full Version : calling up a javascript inside a javascript

06-16-2004, 04: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';

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?

06-16-2004, 11:02 PM

location.href = 'script.js';


06-17-2004, 05: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");

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum