473,545 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

having trouble with event listener: detect iframe close event fromparent

I have an iframe that includes a button:
<input type="button" value="close this window" onclick="window .close();" >

I would like to detect the iframe close event from the parent window, I
was using this code but I did something wrong because the temp function
is fired every time the parent page loads:

function temp(){
alert('the iframe was closed');
}
function setup(){
var myIFrame = document.getEle mentById("ifram e1");
if (myIFrame.addEv entListener) {
myIFrame.addEve ntListener('onc lose', temp(), false);
}else if (myIFrame.attac hEvent) {
myIFrame.attach Event ('onclose',temp );
}else{
myIFrame.onclos e=temp();
}
}
window.onload=s etup;

Any suggestions would be appreciated.

TIA,
Mike
Apr 3 '07 #1
4 26527
On Apr 3, 11:00 am, Mike Scirocco <m...@yahoo.com wrote:
I have an iframe that includes a button:
<input type="button" value="close this window" onclick="window .close();" >

I would like to detect the iframe close event from the parent window, I
was using this code but I did something wrong because the temp function
is fired every time the parent page loads:

function temp(){
alert('the iframe was closed');}

function setup(){
var myIFrame = document.getEle mentById("ifram e1");
if (myIFrame.addEv entListener) {
myIFrame.addEve ntListener('onc lose', temp(), false);
myIFrame.addEve ntListener('onc lose', temp, false);

Apr 3 '07 #2
scripts.contact wrote:
On Apr 3, 11:00 am, Mike Scirocco <m...@yahoo.com wrote:
>I have an iframe that includes a button:
<input type="button" value="close this window" onclick="window .close();" >

I would like to detect the iframe close event from the parent window, I
was using this code but I did something wrong because the temp function
is fired every time the parent page loads:

function temp(){
alert('the iframe was closed');}

function setup(){
var myIFrame = document.getEle mentById("ifram e1");
if (myIFrame.addEv entListener) {
myIFrame.addEve ntListener('onc lose', temp(), false);

myIFrame.addEve ntListener('onc lose', temp, false);
Removing the parens works great in FF, thanks:

myIFrame.conten tWindow.documen t.body.addEvent Listener('click ',temp, false);

Do you have any suggestions about making this work in IE?

Mike
Apr 4 '07 #3
On Apr 3, 11:47 pm, Mike Scirocco <m...@yahoo.com wrote:
myIFrame.addEve ntListener('onc lose', temp, false);
myIFrame.conten tWindow.documen t.body.addEvent Listener('click ',temp, false);

Do you have any suggestions about making this work in IE?

Use attachEvent method for IE or just use onclick=temp
Apr 4 '07 #4
scripts.contact wrote:
On Apr 3, 11:47 pm, Mike Scirocco <m...@yahoo.com wrote:
>>myIFrame.addE ventListener('o nclose', temp, false);
>myIFrame.conte ntWindow.docume nt.body.addEven tListener('clic k',temp, false);

Do you have any suggestions about making this work in IE?


Use attachEvent method for IE or just use onclick=temp
This worked great:

myIFrame.conten tWindow.documen t.body.onclick= temp;

Thank You,
Mike
Apr 5 '07 #5

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

Similar topics

4
7601
by: Thomas | last post by:
Hi there, I have an iframe which is editable (designMode = "on") and want to resize it dynamically as the content grows (e.g. more lines of text is in there) and there the struggle starts. I fill the iframe with content (<body> tag and so on and also insert a <div> tag, inbetween is the content that should be modified). Now if the...
6
14374
by: Wendi | last post by:
If i have an iframe from within an HMTL document: Iframe.htm: ------------------------------ <html> <head> <title>Iframe.htm</title> </head> <body> <iframe src="sample.htm"></iframe>
2
10090
by: Craig | last post by:
Hi I listen on a port, when data is received I raise an event (OnMessageReceived) in the while loop as follows: private void WaitForConnection() { TcpListener listener = new TcpListener(IPAddress.Any, 1234); Stream data = null; Socket socket = null;
1
1551
by: stw | last post by:
I am not sure how to go about creating a "frame listener" (as it is known in Java circles) in C# in ASP.Net. In essence, I to enable a parent frame to listen for, and to handle specific javascript calls from a child iFrame I have an asp.net page with an embedded iFrame. The initial iFrame source is determined by the parent frame UI. The iFrame...
2
2093
by: jdlwright | last post by:
Hi all, I busted a gut getting my design-mode iframe to work properly in FF1 and IE, and just when I thought everything worked nice I discovered that in FF1.5 event handlers in the iframe are no longer processed; http://developer.mozilla.org/en/docs/Rich-Text_Editing_in_Mozilla they infer that event handlers were never handled, but they...
2
3140
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early...
6
7510
by: Gregor Kofler | last post by:
I'm trying to "detect" a keydown event in a DIV. The idea have a keydown listener attached to document and forward the event to the div. (I've searched the web, but it was impossible to handle the noise on this topic.) I've tried a simple prototype in Firefox and it seems to work. function forward(e, elem) { var f, p;
5
13314
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the...
0
7468
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7401
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7757
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5972
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4945
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
704
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.