You are viewing limited content. For full access, please sign in.

Question

Question

Open a link in a new popup window

asked on March 13, 2019

I am trying to open a link in a new popup window but the link always open either in same page or in a new tab.

see below my code:

$(document).ready(function() {
  $('.link [type="text"]').each(function(e,el){
   var link=$(el).val();
    var link2=$(el).val();
    link2= "link"
   $(el).replaceWith($('<a href="' + link + '"return !window.open"  target="_new">' + link2 + '</a>'));


  });
  });

0 0

Replies

replied on March 13, 2019

window.open is the correct method, but I'm pretty sure the default behavior for modern browsers is to open a new tab instead of a separate window.

1 0
replied on March 13, 2019

Have you tried using target="_blank" instead?

1 0
replied on March 13, 2019

Yes i tried with _blank but still it opens in a new tab

0 0
replied on March 14, 2019

You can't force a new windows rather than a tab by changing the link's target attribute, because that's controlled by the user's browser settings. According to the internet, you'd have add more JavaScript to do that.

0 0
replied on March 26, 2019

i was able to do the pop see reply above

0 0
replied on March 13, 2019

you could also try using javascript's

alert(...);

0 0
replied on March 25, 2019

Hello

i was able to do the pop link:

find code below

 


$(document).ready(function() {
  $('.link [type="text"]').each(function(e,el){
   var link=$(el).val();
    var link2=$(el).val();
  link2= "link"
   
   $(el).replaceWith($('<a ="' + link + ' target="_blank"  id = "test">' + link2 + '</a>'));
test.onclick = function ShowWindow() { 
    window.open(link, 'popUpWindow', 'height=300,width=600,left=100,top=30,resizable=Yes,scrollbars=Yes,toolbar=no,menubar=no,location=no,directories=no, status=No');
}

  });
  });

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.