Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Base Href

Status
Not open for further replies.

royweb

Programmer
Aug 27, 2003
11
0
0
US
I have a <base href="page1.html"> in the <head> section and want to change that URL based on a checkbox.

Sample code:

function change_base_href()
{
if (change_url.checked)
}

Can someone provide me the javascript code that makes the "base href" to change to another URL?

Thank you.
 
I don't think you can dynamically do this on the fly..... It would be like trying to dynamically change the src of an imported javascript or css file.... I don't think you can change the values of most stuff defined in the <head> section.

I guess this is worth a shot, but if it doesn't worth then it's probably not possible:
Code:
<html>
<head>
<base href="[URL unfurl="true"]http://www.blah.com/images/"[/URL] [!]id="myBase"[/!] />

<script type="text/javascript">
function changeBase(obj) {
   if (obj.checked) {
      document.getElementById("myBase").href = "[URL unfurl="true"]http://www.somethingdifferent.com/";[/URL]
   }
}
</script>
</head>
<body>
<input type="checkbox" onclick="changeBase(this)" />change the base
</body>
</html>

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top