Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How come return false prevent redirection of link ?Urgent Re: How come return false prevent redirection of link ?Urgent

#62947
Snoopy
Member

Hello everyone

Refering to last post where is mention tht it was not working on google chrom , opera ,safari, ie 6 , ie 7 .
I found another way where is working on ie7, ie6 , firefox but unfortunately :( it is NOT WORKING on google chrome, opera, safari . In google chrome, opera, safari the page keeps on reloading , can someone help , desperately need to fix it . Than k your kind help :)
Can u someone help me

function fireEventSport(element,event){
if (document.createEventObject){
// dispatch for IE
var evt = document.createEventObject();
return !element.fireEvent(‘on’+event,evt)
}
else{
// dispatch for firefox + others
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true ); // event type,bubbling,cancelable
return !element.dispatchEvent(evt);
}
}
$(function(event)
{
var $url = window.location.href;
var $arrAnchor = document.getElementsByTagName(‘a’);
var $id;

for(i=0,count=$arrAnchor.length;i<count;i++)
{

if($url.indexOf($arrAnchor.href)>-1)
{
$id = $arrAnchor
.id;

break;

}
}

fireEventSport(document.getElementById($id),’click’);

});