Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Can you post the JS you are entering?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
This forum post may help:
Re: Call functions from external javascript library in xapi(.zip) and swf content