javascript - How to change current URL and open new tab on click using jQuery -
i need replace every link on page has current url like:
("body a").on("click", function() { window.open("new_page.html?test=1&test=2", "_newtab"); window.location.replace('replace_current_page.html?test=1&test=2'); });
i'm not sure window.open right function. maybe replacing href better idea?
if has every link, need go same page? i'm not sure need well.
/* allows open link in new window */ $(function() { $('a').each(function() { $(this).attr('target', '_blank'); /* uncomment if need change href here $(this).attr('href', "mylink.htm"); */ }); });
Comments
Post a Comment