Avoid browser popup blockers
The general rule is that popup blockers will engage if window.open
or similar is invoked from javascript that is not invoked by direct user action. That is, you can call window.open
in response to a button click without getting hit by the popup blocker, but if you put the same code in a timer event it will be blocked. Depth of call chain is also a factor - some older browsers only look at the immediate caller, newer browsers can backtrack a little to see if the caller's caller was a mouse click etc. Keep it as shallow as you can to avoid the popup blockers.
Legally avoiding popup blocking
No much you can do. You could ask your users to disable pop-up blockers or inform them that a pop-up blocker is enabled by checking the window object ref returned by window.open()
e.g.
var w = window.open('http://domain.com');
if(!w) {
//an alert in this example
alert('oops..seems like a pop-up blocker is enabled. Please disable');
}
you could find another way and try what Brad suggests.
Related Topics
Pass Props to Parent Component in React.Js
What Is Meant by 'First Class Object'
Asynchronously Load Images with Jquery
Getting Value of Select (Dropdown) Before Change
Get String in Yyyymmdd Format from Js Date Object
Long Processing Time Likely Due to Getvalue and Cell Inserts
Event Handlers Inside a JavaScript Loop - Need a Closure
Invariant Violation: Objects Are Not Valid as a React Child
Passing Environment-Dependent Variables in Webpack
How to Convert an Array of Objects to Object with Key Value Pairs
Call Static Methods from Regular Es6 Class Methods
Cross Browser JavaScript (Not Jquery...) Scroll to Top Animation
Detecting When User Scrolls to Bottom of Div with Jquery
Assigning Prototype Methods *Inside* the Constructor Function - Why Not
Angularjs with Django - Conflicting Template Tags
Browser JavaScript Stack Size Limit
Dynamically Add Script Tag with Src That May Include Document.Write