472,779 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

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 18170


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
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.