473,499 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

iframe IE javascript onload problem

Hi,
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.
but,
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?

Thanks,
Saayan

The /secure/download.php looks like this:

<?php

if(!empty($_GET['dl_file']))
{
// check the valid files here
// and don't accept random requests
// potentially naughty :)

// can read the db here for valid list
// TODO
// 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";

readfile("$path/$filename");
exit();
}
}

?>

Jul 17 '05 #1
2 7428
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.

<?php

if(!empty($_GET['dl_file']))
{
if($_GET['dl_file'] == 'test.txt')
{
exit();
}

}

?>

Jul 17 '05 #2
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
above.

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
setWidth
// 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;
window.clearInterval(minmax_scanner);
setWidth();
}

minmax_scan();
minmax_scanner= window.setInterval(minmax_scan, minmax_SCANDELAY);

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9343
by: Csaba2000 | last post by:
I want to be able to embed a single quote into an INPUT element within a dynamically generated IFRAME. The example below shows how the IFRAME is generated. Challenge: I'd like the alert box to...
3
8099
by: Russell | last post by:
I have a quirky issue that I believe involves timing and only 2 hairs left to pull. I have a modal dialog that is an IFrame. The IFrame contains another window - which contains the appropriate...
3
8322
by: Greg | last post by:
Javascript Folks, I am relatively new to javascript and am working on a script where I want to utilizes a couple of iframes and format text in them. I have run into a problem with getting the...
16
7051
by: Mcginkel | last post by:
I am trying to find a way to load XHTML content in an Iframe. I use to do this in html by using the following code : var iframeObject = document.createElement("iframe");...
3
3926
by: Stevie_mac | last post by:
It might be me but... I dont seem to get a Page_Load event when a opening an ASPX in an iFrame. I do geta Page_Load event when an item on the ASPX (inside the iFrame) is clicked but then...
9
11139
by: aatcbbtccctc | last post by:
Hi folks I've googled for an answer to this, with no success. Can someone please jump in, and put me out of my misery! (I'm sure it's quite simple) I have an invisible IFRAME, and a visible...
4
2517
by: Drew | last post by:
This might beyond the scope of this group because it deals with SharePoint, but I'm not sure if I can't get it to work because of SharePoint or because JavaScript is weird (I don't have much...
3
5362
polymorphic
by: polymorphic | last post by:
I have succeeded in embedding PDF files in a dynamic iframe. The problem is that I need the PDF to cache. If the PDF remains the same from page load to page load then the pdf is somehow cached with...
3
2946
by: whatever0 | last post by:
Hi, I'm fairly new to javascript and was hoping i could have a little help... I have a page containing a form and an iframe. The iframe is initially empty (src="about:blank"). The target of...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.