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

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -