I have to look for clicks on anchor tags, as and when they happen and log them. The jQuery delegate event handler for clicks is stopping the default behaviour of links in IE (i.e clicking on links doesnt take me to a new page, or whatever the link was really supposed to do), whereas in Firefox things work just fine.
I would be glad if anyone from the community can help me figure this out.
CODE SAMPLE:
function logLink(event,target)
{
//no logging for right click
if(event.which<3)
{
if(filterLinks(target))
{
alert('This will log data');
return true;
}
}
return true;
}
/*
*Method to filter all html links which are to be logged
*/
function filterLinks(linkObj)
{
//go into second phase only if the passed object is a link.
if(linkObj.tagName == 'A')
{
alert('second phase')
if( linkObj.hostname==undefined ||linkObj.hostname==''|| linkObj.hostname==null || $(linkObj).attr('href')=='#' || (!$(linkObj).attr('href')) || $(linkObj).attr('href').beginsWith('javascript',true) || $(linkObj).attr('href').beginsWith('mailto',true))
{
alert('native code');
$(linkObj).css('background','gray');
return false;
}
for(var i=0;i<linkObj.attributes.length;i++)
{
if( !$.browser.msie && anchorTagProperties.indexOf(linkObj.attributes[i].nodeName)<0 )
{
alert('redenned tag has an unknown attribute' + linkObj.attributes[i].nodeName);
$(linkObj).css('background','red');
return false;
}
}
return true;
}
else
{
return false;
}
}
$(function (){
var testVar=undefined;
//adding delegate listener for trackedLink class
$('body').delegate(".trackedLink", "mouseup", function(event){
alert('mouseup');
var returnValue =logLink(event,this);
return true;
});
});