[英]Opening an url in a new tab instead of a popup (after click)
The user clicks a context-menu to create a new item, the item is saved async and a url is opened in a new tab when save is done. 用户单击上下文菜单创建一个新项目,完成保存后,该项目将异步保存,并在新选项卡中打开一个URL。 Thats what I want but Chrome is opening the url in a popup instead of a new tab.
那就是我想要的,但是Chrome在弹出窗口而不是新标签页中打开URL。 When opening the window outside the saveasync-then-handler it works fine (the commented code), but not inside.
在saveasync-then-handler外部打开窗口时,它可以正常工作(注释的代码),但不能在内部运行。 Anything I can do get the same behaviour inside the handler?
我可以在处理程序中执行任何相同的操作吗? I have tried using open.bind(this) but that didn't help...
我曾尝试使用open.bind(this),但没有帮助...
var open = function() {
var win = window.open('/page', '_blank');
win.focus();
};
client.SaveAsync().then(open); // This doesn't work, opens in a popup window
open(); // This works, opens in a new tab
Have the same issue, it's browser protection. 有同样的问题,那就是浏览器保护。 Managed to solve it with a workaround:
设法解决此问题:
var win = window.open('/page', '_blank');
client.SaveAsync().then(function() {
win.open('/page', '_self');
});
The trick is that it works when it's not inside an async request like a response of a http request, so we open it before the request and redirect it after we get the response. 诀窍是,当它不在异步请求之内(例如http请求的响应)时,它就可以工作,因此我们在请求之前将其打开,并在获得响应后将其重定向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.