The Cache: Technology Expert's Forum
Welcome, Guest. Please login or register. September 23, 2019, 11:15:13 AM

Login with username, password and session length

Pages: [1]
Author Topic: IE6 PDF Download onClick & bug workaround  (Read 4006 times)
Olde World Hacker
Offline Offline

Posts: 10096

View Profile
« on: June 15, 2008, 03:55:19 PM »

Jeepers this has to be one of the kludgiest workarounds I've seen in a while.

While working through some issues on a site I noticed that if I have an HREF pointing to a PDF file it opens fine in IE6, but if I use in the onClick of a button, IE reports that "The website is not available at the moment, try again." Uh huh.

After boatloads of testing to make sure that it worked in every other frigging browser in creation (including IE7) it became clear that I needed a workaround. Here it is: I created a input-less form at the bottom of my page inside of a non-displaying div thus:

<div style="display: none;"><form id="testform" method="GET" target="_blank"></form></div>

note also that the method of the form is GET. In the button I call my own submit function thus:

<input type="button" value="Click here to get it!" onClick="openPDF('/pdfs/thePDF.pdf');">

I handle the function like this: pushing the URL I want to open into the action of the form and submitting it:

function openPDF(theURL)
var target = document.getElementById('testform');
target.action = theURL;

Works like a charm in all browsers, including IE 6  Angry


It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks

Valid XHTML 1.0! Valid CSS!