473,473 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

detecting when a frame has loaded the result of a form submit

In my application I have an iframe that is empty (and not visible)
initially, however when a user presses a button a form is
programmatically submitted and the target is set to the IFrame.

I want to detect when the frame has been loaded with the result of the
form submit.

Of course I have tried some event handlers like onload, onactivate,
onreadystatechange, but they do not work in this example. They only
seem to work, when the "SRC" attribute of the "IFrame" is set, e.g.
not when the IFrame is set as the target of the form.

Any ideas on how to do this?

Regards, Halldor
Jul 20 '05 #1
2 18275


Halldór Ísak Gylfason wrote:
In my application I have an iframe that is empty (and not visible)
initially, however when a user presses a button a form is
programmatically submitted and the target is set to the IFrame.

I want to detect when the frame has been loaded with the result of the
form submit.

Of course I have tried some event handlers like onload, onactivate,
onreadystatechange, but they do not work in this example. They only
seem to work, when the "SRC" attribute of the "IFrame" is set, e.g.
not when the IFrame is set as the target of the form.

Any ideas on how to do this?


With Netscape 7 and IE6 the following intially doesn't show the iframe
and then shows it when the form is submitted

<html>
<head>
<title>iframe onload handler</title>
</head>
<body>
<form action="jsInterpreter.html"
target="frameName">
<p>
<input type="text" name="GOD" value="Kibo">
<input type="submit">
</p>
</form>
<p>
<iframe name="frameName" style="display: none;"
onload="if (typeof this.loadCount == 'undefined') {
this.loadCount = 0;
}
this.loadCount++;
if (this.loadCount > 1) {
this.style.display = '';
}"></iframe>
</p>
</body>
</html>

Doesn't work with Opera 7 as that doesn't support
<iframe onload
thus if you need to have it work cross browser you are probably better
off to use the onload handler of the page to which the form is submitted.
However when I try the following as the containing page

<html>
<head>
<title>iframe onload handler</title>
</head>
<body>
<form action="test2003091501.html"
target="frameName">
<p>
<input type="text" name="GOD" value="Kibo">
<input type="submit">
</p>
</form>
<p>
<iframe name="frameName" id="frameName" style="display: none;"></iframe>
</p>
</body>
</html>

and the following as the frame page

<html>
<head>
<title>iframe load test</title>
<script type="text/javascript">
function showFrame () {
if (window != parent) {
if (document.getElementById) {
var iframe = parent.document.getElementById(this.name);
iframe.style.display = '';
}
}
}
</script>
</head>
<body onload="showFrame();">
<p>
iframe load test
</p>
</body>
</html>

then it still doesn't work with Opera 7 as that opens a new window to
submit the form to, probably as the iframe with display: none is not
considered a form target.
When I change the containing page to

<html>
<head>
<title>iframe onload handler</title>
</head>
<body>
<form action="test2003091501.html"
target="frameName">
<p>
<input type="text" name="GOD" value="Kibo">
<input type="submit">
</p>
</form>
<p>
<iframe name="frameName" id="frameName"
style="visibility: hidden;"></iframe>
</p>
</body>
</html>

and the frame to

<html>
<head>
<title>iframe load test</title>
<script type="text/javascript">
function showFrame () {
if (window != parent) {
if (document.getElementById) {
var iframe = parent.document.getElementById(this.name);
iframe.style.visibility = 'visible';
}
}
}
</script>
</head>
<body onload="showFrame();">
<p>
iframe load test
</p>
</body>
</html>
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
The target of the form can return html containing some javascript that
notifies your app of success or failure (provided they are in the same
domain)

Hope that helps
Jul 20 '05 #3

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

Similar topics

9
by: Mark | last post by:
I have a working PHP/MySQL application used for data entry. The data entry screen includes a "Save" button. The PHP code for this button looks like this: if (isset($_POST)) { if ($_POST ==...
1
by: Unregistered | last post by:
I'm making an Intranet site for someone who is not very familiar wit making websites, thus I would like to make it as simple as possible fo her when she needs to update it. The intranet site...
3
by: foldface | last post by:
Hi Given a web page using frames, is there anyway the left frame can request a page in the right frame and, most importantly, detect when it has fully loaded? Ideally this requires no changes to...
2
by: Colin McKinnon | last post by:
Hi all, I've got two frames, one with a form ('main') and one with some clickable images ('tp'). The clickable images call a function in 'main' (code below) which in turn calls the .submit() or...
1
by: Ashish | last post by:
I am looking for javascript code, which can add items in another frame. Scene: I have 3 frames A, B and C. A and C has links/queries that displays result items in B Results are with...
5
by: Tim Johnson | last post by:
Howdy: Let's suppose for illustration that I have a web page with 3 frames: Let's call them 'fStates', 'fCounties', and 'fCities'. On loading the page, fStates has a select list of states and...
1
by: tony wong | last post by:
The page has Top frame (input) and bottom frame (result) The input html page send input to asp to generate result to bottom frame. The page works. But i wish to refresh bottom frame once i...
3
by: Dag Sunde | last post by:
Is there a way to detect if the reason an onUnload() handler was called originated from the user explicitly refreshed the page(s)? Ie. pressed "Ctrl-R", "F5" or klicked the refresh button in...
4
by: Matt | last post by:
I am no JavaScript guru so please bear with me and be as detailed as possible with your response. I thank you in advance. I have an ASP page that contains form elements. I also have an inline...
0
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.