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

Script_Window in Captivate 9 fails with js comments

Engaged ,
Aug 24, 2016 Aug 24, 2016

Copy link to clipboard

Copied

Hi

... just spent the last hour trying to debug some JS code so hopefully this will save someone the headache:

Under the Properties tab, in the Actions panel lies a button called "Script_Window" which is where we're supposed to be able to enter own our javascript.

I found out the hard way that Javascript comments are not welcomed in this script window. Once it encounters these comments in your code it stops processing all together, not just that specific line of code.

Captivate 9 vers 9.0.2.421 on Mac OSX 10.11.6

captivateJScomments.jpg

Views

474

Translate

Translate

Report

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
Adobe Employee ,
Aug 24, 2016 Aug 24, 2016

Copy link to clipboard

Copied

Rich,

That isn't what I'm seeing. I tried your code as above - with the comment and it worked without issue. Cp9.02, Google Chrome. Previewing at HTML5 in browser.

--Allen

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 25, 2016 Aug 25, 2016

Copy link to clipboard

Copied

Whenever functions are involved it is a better practice to insert those in the JS file that gets published with the CP-file and only call the function in the JS window in Captivate. Same for comments. However for just a random number, I would have used the JS API to set a user variable in Captivate to that value wiyh the JS Math functions.

Votes

Translate

Translate

Report

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 ,
Aug 25, 2016 Aug 25, 2016

Copy link to clipboard

Copied

Completely agree with Lieve. because all of the scripts are converted to strings with lot's of escapes, you never know how it will turn out.

I've found that loops are very iffy, single quotes are bad, spaces in a functions arguments can be bad.

The best option is to include a JavaScript file. You can publish, open the JS file and the index in an editor and test you code much easier. Or you can open the "template" JS file in an editor, and test while previewing in a browser without publishing. So much easier.

Votes

Translate

Translate

Report

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
Engaged ,
Aug 25, 2016 Aug 25, 2016

Copy link to clipboard

Copied

I did a little more testing:

I tried these simple JS calls in the script_window:

captivateJSComments2.jpg

and I'm still getting the same behavior with Chrome and FF. (FF 48.0.1) (Chrome Version 52.0.2743.116 (64-bit))

Hope this helps,

Rich

Votes

Translate

Translate

Report

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
Explorer ,
May 09, 2020 May 09, 2020

Copy link to clipboard

Copied

LATEST

I'm having challenges, too, trying to publish in the script window.

 

TLCMediaDesign wrote:

---------------------------------------------

I've found that loops are very iffy, single quotes are bad, spaces in a functions arguments can be bad.

 

The best option is to include a JavaScript file. You can publish, open the JS file and the index in an editor and test you code much easier. Or you can open the "template" JS file in an editor, and test while previewing in a browser without publishing.

-------------------------------------------

I need some guidance about where exactly to put my js code. Does it all go into the index.html file?

Thanks in advance.

 

 

Votes

Translate

Translate

Report

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