i know how to track the click event on anchor tag when href attribute is directly assigned. but instead of assigning href attribute if we give the destination link in onclick function. or when we are loading ajax file how to track the destination url?
Not quite sure what your looking for but I'll give it a try do you mean something like this? When they click on the element it will redirect them?
Post some clearer details and ill edit.
var MyURL = 'http://ABCDEF.com' //Define MyURL
$('#MyElementID').click(function () { //Define the element ID that you click
window.location = MyURL; //Tell it what to do e.g load MyURL
}
Then to figure out what the destination is
$('#MyElementID2').html(MyURL); //Display MyURL in Element
or Alert:
alert(MyURL); //Alert MyURL.
sorry. i will give u detailed information. in a web site a user may enter and click some link. when he clicked a link it will be navigated into another page. i want to track the link on which he clicked.if the hrfe attribute is set in the link i can track by the code $(document).ready(function(){
$("a").click(function(){ var selected=$("this").attr(href); alert(selected);
}); }); but in case if he give the destination url in a onclick event function instead of setting href value then how to track that one.