BASE HREF tag

Discussion in 'Javascript' started by John Smith, Jun 27, 2003.

  1. John Smith

    John Smith Guest

    Is there a way to get Javascript to obey the <BASE HREF=""> tag? I
    have some code that redirects a user to a template on a different
    domain, but it keeps taking me to the current domain.

    Code sample:
    <base href="http://www.example.com">

    <SELECT onChange="location=this.options[this.selectedIndex].value;">
    <OPTION VALUE="shwspool.html">View Spool Directory</OPTION>
    <OPTION VALUE="monacc.html">View Monitor Access Log</OPTION>
    <OPTION VALUE="monsys.html">View Monitor System Log</OPTION>
    </select>

    Any help would be greatly appreciated!
     
    John Smith, Jun 27, 2003
    #1
    1. Advertisements

  2. John Smith

    Lee Guest

    John said:
    Off the top of my head, that's not a valid base href value.
    Try:

    <base href="http://www.example.com/">
     
    Lee, Jun 27, 2003
    #2
    1. Advertisements

  3. John Smith

    John Smith Guest

    :John said:
    :>
    :>Is there a way to get Javascript to obey the <BASE HREF=""> tag? I
    :>have some code that redirects a user to a template on a different
    :>domain, but it keeps taking me to the current domain.
    :>
    :>Code sample:
    :><base href="http://www.example.com">
    :
    :Off the top of my head, that's not a valid base href value.
    :Try:
    :
    :<base href="http://www.example.com/">

    It still didn't solve my original problem, however :(
     
    John Smith, Jun 27, 2003
    #3
  4. Try something like:

    function goto(url) {
    location.href = document.getElementsByTagName('base')[0].href + url;
    }
    ...
    <select onchange="goto(this.options[this.selectedIndex].value)">

    (warning:untested)
    /L
     
    Lasse Reichstein Nielsen, Jun 27, 2003
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.