• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

How to explicitly trigger another frame's onunload event function

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We run into a situation like this:

There are 2 frames in the browser, we have an onunload event in frame No.1 to do some status update. But we have to make sure the frame No.2's onunload event function get called before frame No.1.

Basically, we want to explictly call the other frame's onunload event.

How can we do that? Any help is greatly appreciated.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can just call the function.

parent.framename.functionName();

Eric
 
Felicia K Lei
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!

But that frame is developed by another team, and the function name is unknown. Can we just trigger that frame's onunload event if we do not know the function name for that event?

Meanwhile, We will also try to ask the other team to use a fixed name for onunload event if there is the only choice.

Thanks again.
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use the following for clicking programmatically:



unload might work the same way.

-Yuriy
 
Felicia K Lei
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yuriy,

I am not sure I understand your point. We have found a "stupid" workaround, but it looks ugly.

What we did is to catch the onunload event in frame 1 by function onClose(), and then in the onClose(), we replace the html in frame2, but we have to alert a javascript message to trigger frame 2's onunload event. It seems that simply replacing the frame2 html is not good enough to trigger frame 2's onunload event.

parent.frame2.location.replace("loading.html");
alert("Thank you.");

Can any one help us get rid of this javascript alert message? Or any better solution.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Felicia, I'm not sure if this is what you want, but you could try the following



test2.html:



-Yuriy
 
Honk if you love justice! And honk twice for tiny ads!
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic