Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

window.open does not work in Safari


amitava82

Question

Given following code injected into the page:

var btn = document.querySelector("a[href=#testbtn]");

btn.addEventListener('click', function(){ window.open('https://google.com');});

It does not open new window. The click handler does get called. window.open returns null. Same piece of code tested with a simple html page works fine in same browser.

Edited by amitava82
Initial Revision
Link to post
  • Answers 2
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

2 answers to this question

Recommended Posts

  • 0

@amitava82 Just from the brief bit of code you posted above, I'm assuming you have tag button, that when the user clicks on it you want the link (google.com) to open in a new tab?

If so, you don't need to do this in JavaScript. Simply add the url as the href value and then give it the attribute "target" with a value of "_blank". E.g:

I'm a button

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...