Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How to explicitly trigger another frame's onunload event function

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic