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

Adobe Captivate 2017 - Javascript in advanced actions

Community Beginner ,
Aug 16, 2017 Aug 16, 2017

Hi there,

I'm trying to create an advanced action where I execute two sets of javascript. However, within advanced actions' script window, I enter the script, click okay and get a notification that my action is incomplete. So I click back into the script window and, every time, the script has disappeared. If I want to just create an action (not an advanced action) I'm able to enter and save the script in the execute java script action, but the disappearing script still occurs in advanced actions. Any ideas?

Thanks!

1.1K
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
Advisor ,
Aug 16, 2017 Aug 16, 2017

Can you post the JS you are entering?

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
Community Beginner ,
Aug 16, 2017 Aug 16, 2017

Here's the code:

var shapeID = "Rob";

var fontLink = '<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">';

$(fontLink).appendTo("head");

domStyle =    $('<style> .' + shapeID + ' .cp-actualText {font-family: "Roboto", Roboto !important ;} </style>');

domStyle.appendTo('head');

$('[id^=re-'+shapeID+']').addClass(shapeID);

Otherwise, I'm trying to write an if/then statement in which I say if an object/text box contains "slab" in the title make the font roboto slab, else make the font roboto. If you can help me to figure out this javascript code, then I could just use a regular action and not use advanced actions at all. I don't have coding experience so I'm sure I'm writing my if/then incorrectly.

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
Advisor ,
Aug 16, 2017 Aug 16, 2017

Unfortunately, greater than and less than signs <> do not escape in the Cp code editor... which limits your ability to add HTML tags.  You'll have to add this to an external JS file if you want it to work.

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
Community Beginner ,
Aug 16, 2017 Aug 16, 2017

So in that case, if I wanted to write an if/then statement in a separate JS file, could I use Dream Weaver to do that and then add it to the unzipped files of my project? Or would I add this to the existing CSS file?

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
Advisor ,
Aug 16, 2017 Aug 16, 2017

What version of Cp are you using and are you publishing as SWF or HTML5 or both?  You could alter the published HTML file by adding the script tag of the JS file in the header of the HTML file.  You'd also need to wrap your JS code in a function and call the function from Cp.

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
Community Beginner ,
Aug 16, 2017 Aug 16, 2017

I have Captivate 2017. I'm publishing as HTML5

Oddly the code with the greater/less than signs works if you use it as a simple action in captivate and execute Java Script. It's the advanced action where it breaks.

Some of this may be a little over my head.

Is this how you do a script tag:

<!DOCTYPE html>
<html>

  
<head>
  
<title>HTML script Tag</title>
  
</head>

  
<body>
  
<script type = "text/JavaScript">
  document
.write("You're visiting tutorialspoint!")
  
</script>
  
</body>

</html>

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
Advisor ,
Aug 16, 2017 Aug 16, 2017
LATEST
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