Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Call javascript functions on load and on window close

New Here ,
Apr 05, 2016 Apr 05, 2016

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

1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Apr 05, 2016 Apr 05, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 05, 2016 Apr 05, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Apr 05, 2016 Apr 05, 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()

{

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2016 Apr 08, 2016
LATEST

That sounds like a great idea. I'll try that and let you know. Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources