Skip to main content
Known Participant
August 16, 2017
Question

Adobe Captivate 2017 - Javascript in advanced actions

  • August 16, 2017
  • 1 reply
  • 1237 views

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!

    This topic has been closed for replies.

    1 reply

    Legend
    August 16, 2017

    Can you post the JS you are entering?

    Known Participant
    August 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.

    Legend
    August 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.