Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    calling up a javascript inside a javascript

    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?

  • #2
    Super Moderator
    Join Date
    May 2002
    Posts
    1,041
    Thanks
    0
    Thanked 12 Times in 12 Posts
    Try:

    Code:
    location.href = 'script.js';
    -sage-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,961
    Thanks
    0
    Thanked 236 Times in 233 Posts
    That will open the js file.

    Maybe this is what you want.
    Code:
    var oScript = document.createElement("script");
    oScript.setAttribute("type", "text/javascript");
    oScript.setAttribute("src", "script.js");
    document.getElementsByTagName('head')[0].appendChild(oScript);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •