Is It Possible To Stop Redirection To Another Link Page?
I have already searched a lot, but it seems this can't work. At the program, there is a jquery ready function to make the click event redirect. if($.isFunction(link.attr('onclick')
Solution 1:
I don't understand, what do you mean by "only append new code"? If that means that you cant change the onclick handler or the above code, the solution goes like this:
Identify the link, for which you wish to change the behavior, remove the onclick handler.
$(".someClass a").unbind('click');
Add new onclick handler:
$('.someclass a').bind(function(e){
var url = $(e.target).attr('href');
window.open(url, 'width=200');
}));
All this code should be executed when page loads and all the links you wish to override are in DOM.
$(document).ready(function(){
//unbind links ...
$(".someClass a").unbind('click');
//bind with changed onclick handler
$('.someclass a').bind(function(e){
var url = $(e.target).attr('href');
window.open(url, 'width=200');
}));
});
Solution 2:
If I'm understanding correctly, that jQuery block is to only run the onclick if one exists otherwise it simulates a normal hyperlink click.
So if you want it to just open in a new window, and you can't change the jQuery an option would be to add an onclick event:
<ahref="aaa"onclick="window.open(this.href);return false;">Link1</a>
This should execute as the onclick open in a new window.
Post a Comment for "Is It Possible To Stop Redirection To Another Link Page?"