Copy link to clipboard
Copied
ok, so when we put the folowing into the top of moodle LMS on theplayer.php page:
<script type="text/Javascript">
function myFunction(){
alert('Hello world");
}
</script>
and we setup a button to fire this script :
"myFunction();"
we get an error :
Uncaught ReferenceError: myFunction is not defined
is there something that we are doing wrong here ? all the tutorials that we have read says we should be able to do this quite simply with capivate 6.
its on a webserver(dreamhost) and still not working.
Copy link to clipboard
Copied
Check your quotes around Hello World...
Jim Leichliter
Copy link to clipboard
Copied
I have edited that to fix it .. turns out I had it wrong in here.. it was single quote in the CP file. still not working
am I wrong in what im thinking ? should it work this way ?
Copy link to clipboard
Copied
No, you're not wrong in thinking that it should work that way... but where you put your JS functions depends on what you're trying to do.
Instead of altering the LMS (Moodle), you probably want to include your JS functions inside the standard.js file that Captivate outputs. You can call those functions from inside Captivate just the same as if the function was defined in the php or html page. Using the standard.js file gives you two distinct advantages:
1. It gives you the flexibility to alter your JS funcitons from course to course... and apply consistency from course to course.
2. If you modify the standard.js file in your Captivate installation directory, you can have these JS functions available during testing... and the file gets automatically get coped to the publishing output folder when you publish. No manual copy/paste.
Jim Leichliter
Copy link to clipboard
Copied
Thanks for the response Jim,
The problem with that solution (which I tried and works) is that I'm trying
to access some elements from within the DOM, and it feels like the CP
program is inside of an iframe or something ?..
at any rate is there a way to access functions from outside the CP realm? I
see lots of examples however I cant get it to work.. is there a switch that
i need to throw in CP to make it work or something .. its very frustrating.
perhaps even just do something simple like return the innerHTML of a DOM
element ?
Copy link to clipboard
Copied
Thanks for the response Jim,
The problem with that solution (which I tried and works) is that I'm trying to access some elements from within the DOM, and it feels like the CP program is inside of an iframe or something ?..
at any rate is there a way to access functions from outside the CP realm? I see lots of examples however I cant get it to work.. is there a switch that i need to throw in CP to make it work or something .. its very frustrating.
perhaps even just do something simple like return the innerHTML of a DOM element ?
Copy link to clipboard
Copied
Yes, you can access functions from outside the Cp realm. So if I understand your correctly, you have Cp loading in an iframe and you want to access DOM elements in the parent? Take a look here:
http://stackoverflow.com/questions/935127/how-to-access-parent-iframe-from-javascript
Once you have a JS reference to the parent window, you're free to get crazy!
Copy link to clipboard
Copied
Hey Jim,
No sorry for the confusion, what i said was " and it *feels *like the CP
program is inside of an iframe or something" but its not i checked.. but
ill try this today and hope for the best.
thanks.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more