window.open () is the usual way to open a new window, but it will now be blocked by most browsers, the default is the non-user will open the window, that is, advertising and so on.
But it is possible to open by an event with a link, because it will be assumed that the user is subjective to open another window so it is not intercepted.
There are many ways to solve a blocked problem, and it has not been practiced. This requirement existed in the previous period, when several methods were used, but not in effect, and finally
The way to change location by delay has finally been solved. The following is a practical discussion.
The 1.a tag's direct event will not be intercepted. The code is as follows:
Links.on (' click ', Function (e) {
E.preventdefault ();
var _this = $ (this);
window.open ('/bookmerchant/fun/');
}
After the 2.ajax request, the new open window operation is intercepted, even if the A-linked event is started. As follows:
Self.addBtn.on (' click ', Function (e) {
/*AJAX Request omitted */
}). On (' Success ', function (res) {
if (Res.code = = 200) {
var cusid = res.data.customerId;
window.open ('/bookmerchant/fun/');
}。
The window.open () is not feasible at this time.
The solutions you see online:
1. Create a tag then, bind the event, and then JS Trigger. This is also intercepted in my actual operation.
2. Open the label window.open () before the request, and then change the location after the request is accepted, so it is possible.
var newtab=window.open (' About:blank ');
/*ajax Request */
}). On (' Success ', function (res) {
if (Res.code = = 200) {
newtab.location.href= '/bookmerchant/fun ';
}
3. Another way is to open the new label window.open (), and then through the settimeout () to delay the setting of location, the same principle should also be feasible (no practice here, so do not dare to say certain).
Windows that can't be opened _____window.open