Skip to main content
Participating Frequently
April 5, 2016
Question

Call javascript functions on load and on window close

  • April 5, 2016
  • 1 reply
  • 1836 views

Hi guys,

is there a way to call a javascript function when the page is loaded and when the window of the browser is closed or changed. I know a can do that via js editing the html file, but is there a way to set that on captivate so that my client doesn't have to write it manually?

Thanks

This topic has been closed for replies.

1 reply

TLCMediaDesign
Inspiring
April 5, 2016

Are you talking about using the JS window in Captivate?

I don't think you'll be able to do that. The window.onload event will already have passed by the time CP is loaded.

What do you mean about the client having to write it manually?

Participating Frequently
April 5, 2016

Yes, I'm talking about listening the js window events onbeforeunload and load from captivate itself.

I'm developing a captivate project that will be used ad starting point for other projects. If i could punt this scripts inside the project, my client wouldn't have to open every html file and write the script manually.

TLCMediaDesign
Inspiring
April 5, 2016

My suggestion then is to put the scripts in the head of an blank html page. Zip the file and insert on the first slide and display for rest of project. It will always be there then. I don't think you can get them to work from inside the JS window.

not sure this one will work, it may already be fired

window.parent.window.onload = function()

{

}

try this if it doesn't fire

window.onload = function()

{

}

window.parent.window.onunload = function()

{

}