amitava82 Posted July 19, 2019 Share Posted July 19, 2019 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. Link to comment
accordJulian Posted July 19, 2019 Share Posted July 19, 2019 @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 comment
amitava82 Posted July 19, 2019 Author Share Posted July 19, 2019 Well of course. This is just a simplified example to demonstrate the issue. Our clients use our widget on squarespace and it is breaking due to this bug. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.