Scott Klarenbach
Scott Klarenbach

Reputation: 38721

open pdf file from javascript?

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?

Upvotes: 1

Views: 11786

Answers (2)

palswim
palswim

Reputation: 12140

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.

Upvotes: 0

Dustin Laine
Dustin Laine

Reputation: 38503

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>

Upvotes: 2

Related Questions