Forum Moderators: open
will this function do the same as clicking on a link but with the addition of using window.replace method or is it wrong constructed?
function replacer(){
var isIe = (navigator.appName == "Microsoft Internet Explorer");
var isOpera = (/opera/i.test(navigator.userAgent));
if(isOpera ¦¦ isIe) {
var allClickedLinks = document.getElementById('gallery').getElementsByTagName('a').length;
var clickedLinks = document.getElementById('gallery').getElementsByTagName('a').href
for (var i = 0; i <= allClickedLinks - 1; i++) {
window.location.replace( 'clickedLink');
}
}
<script type="text/javascript">
function repLnk(){
var anchs=document.getElementById("divOne").getElementsByTagName("a");
for(var i=0;i<anchs.length;i++){
if(anchs[i].href){
anchs[i].onclick=function(){
location.replace(this.href);
return false;
}
}
}
}
window.onload=repLnk;
</script>