html - Javascript: Clicking Link to Download pdf -
I am working on a JS program for which web pages should open www.mysite.com & amp; To download a PDF click on a link within that webpage to click, the link looks like this:
& lt; One onclick = "download (); return back;" Href = "# number" "gt; click to download & lt; / a & gt; Generally, by clicking on the link manually, download PDFs The following function calls:
function download () {document.forms [0] .action = path + "/xxW04_sv_0140Action.do"; Document.forms [0]. Target = "_self" "; Document.forms [0] .submit ();} The JavaScript code is simplified to open my code page and click on the" Click to Download "button Do this:
& lt ; Script & gt; Var link name = "http://www.mysite.com"; Var windowname = "window_1" // opens a new window myWindow = window.open (Lincoln, WindowMenu, "width = 400, height = 600 "); // should download a link to download PDF myWindow.document.getElementById ('href = \" #navn \ "') Click (); & lt; / script & gt; So far, I can open the webpage "mysite.com" in a separate window, but for some reason no button is clicking and certainly no PDF has been downloaded. Click on the "Download to Click" button to download manually.
Can anyone tell me what I am doing? Why can not I simulate a click with the above JS code?
Or maybe give me some things to try
Update: From the initial answers given below, this method might be wasted for failure has given! Is there a better suggestion that I can download these PDFs?
You can better use:
& lt; A href = "http://www.mysite.com/mypdf.pdf" & gt; It should download that PDF file.
Comments
Post a Comment