window.open(URL)不同的行为 - 同code,不同的时序 [英] window.open(url) different behavior - same code, different timing

查看:126
本文介绍了window.open(URL)不同的行为 - 同code,不同的时序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ExtJS的应用程序。当用户需要查看PDF格式的报告在服务器端生成的我打开使用 window.open()功能的新链接。我通过网址服务,提供存储在Web服务器上的PDF文件。

I have a ExtJs application. When user needs to view PDF report generated on the server side I open a new link using window.open() function. I pass URL for service that provides PDF file stored on the web server.

这个功能是从两个不同的地方叫:用户可以滚动的报告列表,点击其中一个工具栏按钮,看到该报告,或者用户可以执行报告,等到它生成,然后程序会自动present它。两个方案之间的唯一差别 - 第二个是异步和最后步骤,其中报告是开放从回调函数调用。

This function is called from two different places: user can scroll list of reports and click toolbar button on one of them and see the report, or user can execute report, wait till it generated and then application will automatically present it. The only difference between two scenarios - second one is async and the last step where report is open is called from callback functions.

不过,这两种情况下表现不同。第一个 - 将在Chrome中打开新的标签,并在Safari浏览器,这将不被视为一个弹出窗口。在第二种情况 - 它将会在新窗口中打开(当然在同一个浏览器 - 这样的配置是完全一样的)。

But these two cases behave differently. First one - will open new tab in Chrome, and in Safari and this will not be considered a popup window. In second case - it will be opened in new window (in the same browsers of course - so the configuration is exactly same).

我坚持要弄清楚为什么行为是不同的。

I'm stuck to figure out why the behavior is different.

任何想法?

更新:澄清 - 两者都是JS调用。一个是这样的:

Update: To clarify - both are JS calls. one is something like:

buttonClick: function() {
   window.open('myreporturl');
}

另一种是一个比较复杂一点,但在最后:

other is a bit more complicated but at the end:

runReport: function() {
   store.on('load', function {
      window.open('myreporturl');
   });
   store.load();
}

UPDATE2:我能搞清楚是怎么回事。如果JS用户启动的事件(用户点击基本)后,立即打开对外窗口 - 它被通过浏览器新标签处理。如果我把为同一按钮单击事件处理一个5秒的延迟 - 它被视为新窗口

Update2: I was able to figure out what's going on. If JS opens external window immediately after user initiated event (user click basically) - it gets treated by browser as new tab. If I put a 5 sec delay for the same button click event handler - it gets treated as new window.

是否有意义任何人?

推荐答案

我能够弄清楚发生了什么事情。如果JS用户启动的事件(用户点击基本)后,立即打开对外窗口 - 它被通过浏览器新标签处理。如果我把为同一按钮单击事件处理一个5秒的延迟 - 它被视为新窗口

I was able to figure out what's going on. If JS opens external window immediately after user initiated event (user click basically) - it gets treated by browser as new tab. If I put a 5 sec delay for the same button click event handler - it gets treated as new window.

是否有意义任何人?

这篇关于window.open(URL)不同的行为 - 同code,不同的时序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆