0

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.

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.

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.

Any idea?

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: 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.

Does it make sense to anybody?

Saket Patel
  • 6,573
  • 1
  • 27
  • 36
sha
  • 17,824
  • 5
  • 63
  • 98
  • is this an extjs window or just a regular browser window – dbrin Mar 20 '12 at 20:12
  • regular browser tab/window. it's external PDF file and I didn't want to embed into ExtJs window – sha Mar 20 '12 at 20:14
  • is one an html link and another js method call? Post the actual code that calls the window.open – dbrin Mar 20 '12 at 20:32
  • Both are js calls. That's the strangest part. Included some code snippets. – sha Mar 20 '12 at 20:52
  • 2
    hmm indeed I don't see a difference. I wonder if the browser treats them differently because one is a direct user action response (button click) while the other is based on a timeout? – dbrin Mar 20 '12 at 21:40
  • That's what I was thinking too. Is there way to execute command in the main thread in JS? – sha Mar 20 '12 at 22:24
  • well there is really only one thread, but try executing a button click in the call back method - perhaps that will trick the browser into thinking there is a user interaction. – dbrin Mar 20 '12 at 23:50
  • Is there any specific reasons why you are not using an Ext.Window? – Daniel Ribeiro Mar 21 '12 at 11:12
  • Well, I just feel like this is external document, in PDF format. Users will save it anyway. Just doesn't feel right to put it inside Ext.Window and try to hide the fact that it can be saved locally... – sha Mar 21 '12 at 11:14
  • It's timing. I posted an update to the question. – sha Mar 22 '12 at 15:02

1 Answers1

1

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.

Does it make sense to anybody?

sha
  • 17,824
  • 5
  • 63
  • 98
  • I'm experiencing the same issue as you, also trying to open a PDF in a new window. Did you solve this in the end? What about the dummy onclick event? – okyanet Jun 09 '12 at 04:16
  • Yes. I solved it by adding confirmation box before showing the report. So first report is being generated for some time, then when it's ready - I show confirmation box, and after user clicks there - present report. – sha Jun 09 '12 at 11:22