Reputation: 4546
In my JSP application, I have a javascript function that opens a new window. The reportURL is a call to an asp application that produces a pdf file. So, if you call that asp page, it will produce pdf data.
The javascript that I have is:
function openReport(id)
{
window.open('<%=reportUrl%>&id='+id,
'_blank',
'width=900 height=900 scrollbars=yes status=yes'
);
}
Now my application runs fine, when the report link is clicked, it opens a new window and I can view my pdf. However, when I close the pdf report window and click the link again to generate report, it opens a new window (without the pdf). This new window does not look like a blank window as the background is not white, rather it looks like the pdf plugin for the browser recognizes it is pdf as I can see grey background but I cannot view the document.
Can anyone please let me know where is the problem?
Upvotes: 4
Views: 2499
Reputation: 27224
My guess is its a caching issue of some kind. Whether its caching the window itself, or the results of the URL I can't tell without investigating it. Two things I would try, naming the window with a random name that changes every time you click it so instead of '_blank' use (new Date()).toString()
(or similar I haven't tested it). The second thing to try is to ensure that the URL is unique every time to avoid caching there, so choose a querystring variable thats not used by the reporting system and change that every time its clicked e.g. + 'version='+(new Date()).toString()
.
This jquery popup window code works if you click it twice, so be helpful in determining what works and what doesn't http://swip.codylindley.com/popupWindowDemo.html
In fact you can conduct your own test, change the URL in your popup to a regular website and see how it works, if it works normally you know its the content not the window.
Hopefully that gives a starting point - unfortunately its hard to give a exact answer without being able to reproduce the problem.
Upvotes: 2