How to download a pdf link?
suppose we have a pdf url (like "") now i have to create a button on click of which it downloads that pdf.
i have tried method in javascript but it opens it in another window.
is there a way to download a pdf link using javascript or ajax.
a java code also is appreciated

download a pdf link

This will open a .pdf in the same window (unless your browser or viewer is configured not to do so).

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 25 March 2009), see">
<button onClick="window.location='http://---whatever---.pdf'">Open .pdf!</button>

i do not want to open it in the same window( or another window), i want that if user clicks the button it gets an option to save the pdf file.

That function is available only in IE, and even there it is commonly disabled for security reasons. Just make a regular link and let those who wish to take the risk use right-click to save the file.