473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

UnLoad out of body

Hello All,

Has anyone of you a working sample how to code an UnLoad method out of body
tag with javascript?

I have a common problem where a javascript function should be called after a
certain window is closed. I can't add javascript to window's body tag
because it's a third party code.

So a working sample in IE and Firefox would be great,

Cheers
Oct 23 '08 #1
2 1871
Jone schreef:
Hello All,
Hi
>
Has anyone of you a working sample how to code an UnLoad method out of body
tag with javascript?
Yes, it is simple: just add the eventhandler to the body or document.

>
I have a common problem where a javascript function should be called after a
certain window is closed. I can't add javascript to window's body tag
because it's a third party code.
That might be more difficult.
Your 'parentdocument' (opener from the perspective of the just opened
page) cannot modify the newly opened window (since you said it is third
party, probably meaning other domain???).
>
So a working sample in IE and Firefox would be great,
You can however try this:
- from the opener query the newly opened window for its property 'closed'.

Here is an example.

<script type="text/javascript">
var myWinRef;
function openWin(){
myWinRef = window.open("http://www.google.com","winname");
startPolling();
}

function startPolling(){
document.forms.testform.output.value="myWinRef['closed']="+myWinRef['closed'];
window.setTimeout("startPolling();",1000);
}
</script>

<form action="" name="testform">
<input type="button" onClick="openWin();" value="Click me open new
window and try to add eventhandler">
<input type="text" name="output" size="60">
</form>

You will see the text in the field 'output' will change from false to
true when you close the new window.
This will work in FF3 and IE7. I have no clue which other browsers
support this 'closed' property... You'll have to find that out yourself.
>
Cheers

Regards,
Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
Oct 24 '08 #2
Thanks Erwin,

This approach really solved my problem!

Cheers,

"Erwin Moller"
<Si******************************************@spam yourself.comwrote in
message news:49*********************@news.xs4all.nl...
Jone schreef:
>Hello All,

Hi
>>
Has anyone of you a working sample how to code an UnLoad method out of
body tag with javascript?

Yes, it is simple: just add the eventhandler to the body or document.

>>
I have a common problem where a javascript function should be called
after a certain window is closed. I can't add javascript to window's body
tag because it's a third party code.

That might be more difficult.
Your 'parentdocument' (opener from the perspective of the just opened
page) cannot modify the newly opened window (since you said it is third
party, probably meaning other domain???).
>>
So a working sample in IE and Firefox would be great,

You can however try this:
- from the opener query the newly opened window for its property 'closed'.

Here is an example.

<script type="text/javascript">
var myWinRef;
function openWin(){
myWinRef = window.open("http://www.google.com","winname");
startPolling();
}

function startPolling(){
document.forms.testform.output.value="myWinRef['closed']="+myWinRef['closed'];
window.setTimeout("startPolling();",1000); }
</script>

<form action="" name="testform">
<input type="button" onClick="openWin();" value="Click me open new window
and try to add eventhandler">
<input type="text" name="output" size="60">
</form>

You will see the text in the field 'output' will change from false to true
when you close the new window.
This will work in FF3 and IE7. I have no clue which other browsers support
this 'closed' property... You'll have to find that out yourself.
>>
Cheers

Regards,
Erwin Moller

--
"There are two ways of constructing a software design: One way is to make
it so simple that there are obviously no deficiencies, and the other way
is to make it so complicated that there are no obvious deficiencies. The
first method is far more difficult."
-- C.A.R. Hoare

Oct 25 '08 #3

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

Similar topics

5
by: Harry J. Smith | last post by:
I have written a Visual Basic program that does a long calculation and writes the results to disk as it runs. If I click the Close button the window closes but the program keeps running. How can I...
0
by: razheev | last post by:
Hi, I have a Table which contains 1 million rows. I want to do an unload of the table and do some massaging (tranforming) of data and do a load to a different table where the column attributes are...
1
by: hal | last post by:
I have an application that includes an activex component that consumes resources that must be released when the a page is unloaded. Toward this end I subscribe to the unload event of the body...
1
by: Hal | last post by:
My most sincere gratitude to anyone who can help me work around this! I have work that needs to be done in javascript on the client whenever a page is unloaded. To this end, I subscribe to...
3
by: Gauthier Segay | last post by:
Hello, I've an application where all my pages implement a PAGE_CODE string property, this property is stored in HttpContext.Current.Items. In some page, I must persist data in session while...
2
by: Owen.Leibman | last post by:
Here is a complete web page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <html> <head> <title>Javascript Embed and onunload</title> <script type="text/javascript"> function useplayer() {...
11
by: Timofmars | last post by:
I'm try to Unload DB2 data from a table into a record sequential file on NT. I can an unload on Mainframe, but it doesn't seem to be an option in NT. In NT, all I can do is export/import. I can...
1
by: iamnidheesh | last post by:
i want check a condition on body unload(java script)the function is working on first unload time. in my application some times i have to remain in that page itself so on the second time onwards it...
11
by: Stevo | last post by:
I've been using the unload event for a long time. I have this code, which I've abstracted and made into a stripped down simple test case below, and it works fine on the major browsers (IE5+,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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
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...
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
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...

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.