1

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?

4
  • The only thing I can make of that is an illogical thing to do, could you explain your question in some more detail? Commented Aug 25, 2010 at 21:15
  • I've got a one page application w/ complex UI via ExtJS. Currently reports are firing by opening up another tab in the browser. Instead, I want to fire an Open/Save dialog via javascript without opening a new tab, and without changing the location of the current tab. I've seen it done before, but can't find the code. Commented Aug 25, 2010 at 21:17
  • Why not simply have the webpage download the file, and let the browser handle popping up the "Open? Save?" dialog? Commented Aug 25, 2010 at 21:20
  • I don't want the page to change. It's not a webpage, but an application that is loaded into the current url and maintained by javascript. Commented Aug 25, 2010 at 21:22

2 Answers 2

2

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>
Sign up to request clarification or add additional context in comments.

2 Comments

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

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.

2 Comments

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?
That's only possible when sending the HTTP header, which you can't modify with javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.