I need to open external link in a new window. I handle click on edit button in a view:
module.exports = utils.Backbone.View.extend({
events: {
"click #edit": "onEditClicked"
},
"onEditClicked": () => PubSub.publish("EDITOR_REQUESTED");
});
Then I check if the user is logged in. If yes - I send notification "OPEN_EDITOR" and expect a new window to be open with the external link.
TextEditorController.prototype.handleMessages = function () {
PubSub.subscribe("OPEN_EDITOR", () => {
var editor = window.open(this.$service.getEditorURL());
});
});
But in Safari new window seems to be blocked? Is there workaround in my case?
If you put window. open in a function and call the function with onclick , Safari will not open a new tab. The function must be inside the to click element. A minor correction to the answer: <button onclick='window.
In the Safari app on your Mac, drag the tab over the desktop or choose Window > Move Tab to New Window. You can also drag the tab of one Safari window to the tab bar of another.
open(): This method is used to open the web pages into a new window. Parameters: This method accepts four parameters as mentioned above and described below: URL: It is an optional parameter.
The reason of it is Safari's built-in pop-up blockers.
The only javascript that is allowed to open a new window in Safari - is javascript directly attached to user's event. In your case, you're calling window.open later.
The workaround here can be:
to create a window without a URL in onEditClicked method
safariWindow = window.open();
change that window's URL in handleMessages function
safariWindow.location.href = newUrl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With