By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,480 Members | 1,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,480 IT Pros & Developers. It's quick & easy.

iframe IE javascript onload problem

P: n/a
I have a php generated HTML page, which has a javascript call in the
body tag:

<body onunload="exitPage()" onload="setWidth()" onresize="setWidth()">

In certain cases, there can be an iframe in the page:
<iframe src="/secure/download.php?dl_file=test.txt" style="display:
none" />

This technique has been mentioned by Chung Leong in several posts to
open a file save dialog in the browser (and load the HTML page at the
same time .. 2 HTTP requests).

The problem is:

in Firefox, all works fine, the page loads, the javascript setWidth is
called for onload, and the file dialog appears.
In IE 6, the file dialog shows, but the javascript onload event is
never triggered.

Can anyone help please. Am I missing something here? Any way to get
around this problem in IE?


The /secure/download.php looks like this:


// check the valid files here
// and don't accept random requests
// potentially naughty :)

// can read the db here for valid list
// now only one file, so don't make this
// complex

if($_GET['dl_file'] == 'test.txt')
header("Content-type: application/octet-stream");
$filename = $_GET['dl_file'];
header("Content-disposition: attachment; filename=\"$filename\"");

$path = dirname(__FILE__)."/../download";



Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Observed this:
if the download.php (basically do nothing inside it) is like below,
there is no problem in both Firefox and IE. But, then of course the
file save dialog does not appear.


if($_GET['dl_file'] == 'test.txt')



Jul 17 '05 #2

P: n/a
Workaround (could not have a direct fix) -

Problem - how to call the setWidth() function, even though IE is not
invoking the onload event handler, under the conditions mentioned

Solution =>

In the javascript file (which has the setWidth() function), I added the
following code (simulating the onload event handler):
(Inspiration - minmax.js written by Andrew Clover)

// Scanning. Check document every so often until it has finished
loading. Do
// nothing until the 'content' div arrives, then stop scanning and call
// why need to wait until 'content' div ? Because this div is
manipulated in setWidth()

var minmax_SCANDELAY= 500;

var minmax_scanner;

function minmax_scan() {
if (!document.getElementById('content')) return;

minmax_scanner= window.setInterval(minmax_scan, minmax_SCANDELAY);

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.