BASE HREF tag


J

John Smith

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

Advertisements

J

John Smith

: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 :(
 
Ad

Advertisements

L

Lasse Reichstein Nielsen

John Smith 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">

<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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top