Forum Moderators: open

Message Too Old, No Replies

window.location.replace('clickedLink');

         

webaster

11:36 pm on Mar 13, 2005 (gmt 0)

10+ Year Member



function replacer(){
var isIe = (navigator.appName == "Microsoft Internet Explorer");
var isOpera = (/opera/i.test(navigator.userAgent));
var clickedLink = document.getElementById('gallery').getElementsByTagName('a').href;
if(isOpera ¦¦ isIe) {

window.location.replace('clickedLink');
alert("function works");

}

}

// going back and forth from thumbs to Opera and IE workaround

function iteratorLinks()
{
var galleryLinks; // use local var
if(document.getElementById) // thus getElementsByTagName support assumed
galleryLinks = document.getElementById('gallery').getElementsByTagName('a');
else if(document.all)
galleryLinks = document.all.gallery.all.tags('a');
else return // reject NS4 etc
for (var i=0;i<galleryLinks.length;i++) {
galleryLinks[i].onclick = replacer;

}
}
addEvent (window,'load',iteratorLinks)

webaster

11:45 pm on Mar 13, 2005 (gmt 0)

10+ Year Member



I want to achieve when going over a link that onclick the replacer function gets the href of the iterated a from gallery and does a window.replace

Bernard Marx

12:00 am on Mar 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I hope this will sort it, because this topic has spawned 4 or 5 threads.

function replacer()
{
window.location.replace(this.href);
return false;
}

window.onload = function()
{
var links = document.getElementById('gallery').getElementsByTagName("a");
for(var k=0;k<links.length;k++)
links[k].onclick = replacer;
}