views:

29

answers:

2

How can I return an Open/Save dialog box to a PDF file on the server using only javascript?

I don't want the current pages location to change, however. Do I need to trigger an Iframe?

A: 

You can open a file with the window.open command. The prompt would depend on the user's settings as to what the default action should be.

<a href="#" onclick="window.open('http://linktoPDF', 'NewWin');">link</a>
Dustin Laine
ya, that's what i already have. What I'm trying to do is transparently show it via an iframe (or a better solution) without opening a new window/tab.
Scott
Remove the `, 'NewWin'` portion and it will prompt in same window. The popup is a dialog, so it will not show inside an iFrame, as it will always popup.
Dustin Laine
A: 

Yeah, you'd have to use an iframe for that. You could use the style visible:false; or maybe set the height and width to 1px, but I don't know if display:none; would work. Know that for some browsers, and iframe adds to the history, but it sounds like that isn't a problem.

palswim
ya, cause the main requirement is that the client WANTS an open/save dialog always. They never want the PDF to open up inside of the browser. Maybe this isn't possible?
Scott
That's only possible when sending the HTTP header, which you can't modify with javascript.
palswim