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. Advertising

  2. John Smith

    Lee 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/">
    Lee, Jun 27, 2003
    #2
    1. Advertising

  3. John Smith

    John Smith Guest

    On 26 Jun 2003 20:44:57 -0700, Lee <> wrote:

    :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. John Smith <> writes:

    > 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>


    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 -
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    'Faith without judgement merely degrades the spirit divine.'
    Lasse Reichstein Nielsen, Jun 27, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    757
    John C. Bollinger
    Jan 27, 2006
  2. Sam

    autopostback and <base href...> tag

    Sam, Jun 29, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    137
  3. Weston C

    Getting href attribute of <base> tag?

    Weston C, Jan 2, 2004, in forum: Javascript
    Replies:
    7
    Views:
    279
    Janwillem Borleffs
    Jan 4, 2004
  4. just1coder

    Programmatically change base href tag

    just1coder, Apr 29, 2004, in forum: Javascript
    Replies:
    1
    Views:
    160
    Thomas 'PointedEars' Lahn
    May 15, 2004
  5. Vincent van Beveren

    BASE HREF and A HREF="#" onclick="..."

    Vincent van Beveren, Jul 6, 2006, in forum: Javascript
    Replies:
    2
    Views:
    296
    Vincent van Beveren
    Jul 6, 2006
Loading...

Share This Page