Forum Moderators: open
I need to know how to switch the base ref in mid stream and then change it back to the original after processing some area of the page.
Can it be done someway with variables like shown below?
Of course this does not work. I know if I type actual addresses into each base href, it will work but I need to do it with variables.
When I use <base href="http://www.vahud.com"> it works fine, but I need to use variables to change the ref website.
Can anyone help here?
See example below
<html>
<head>
<script>
orig="http://www.vahud.com/";
ref2="http://www.govhome4u.com/";
ref3="http://www.vahudhome4u.com/";
</script>
</head>
<body>
(This is a photo from vahud.com)<br>
<base href=orig>
<img src= "images/photo1.jpg"><br>
(This is a photo from govhome4u.com)<br>
<base href=ref2>
<img src="images/photo2.jpg"><br>
(This is a photo from vahudhome4u.com)<br>
<base href=ref3>
<img src="images/photo3.jpg"><br>
(This is a photo from vahud.com)<br>
<base href=orig>
<img src="images/photo3.jpg"><br>
</body>
</html>
<script type="text/javascript">
function setbasehref(basehref) {
var theBase = document.getElementsByTagName("base");
theBase[0].href = basehref;
}
</script>
<base href="[full URL here]">
</head>
<body>
<script>setbasehref('[some other URL here]');</script>
<img src="...">
<script>setbasehref('[another URL here]');</script>
<img src="...">
<html>
<head>
<script type="text/javascript">
function setbasehref(basehref) {
var theBase = document.getElementsByTagName("base");
theBase[0].href = basehref;
}
</script>
<base href="http://www.hudandvahome.com/image/">
</head>
<body>
Present the first image with href set to hudandvahome.com/image/<br>
<img src="C7613.JPG"><br>
Present the second image with href set to vahud.com/vahud/images/<br>
<script>setbasehref('http://www.vahud.com/images/');</script>
<img src="lg_ball2644.jpg"><br>
Present the third image with href set to govhome4u.com/images/<br>
<script>setbasehref('http://www.govhome4u.com/images/');</script>
<img src="va_but.gif"><br>
</body>
</html>