Skip to main content
February 26, 2013
Question

JavaScript : Uncaught ReferenceError

  • February 26, 2013
  • 1 reply
  • 1874 views

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.

This topic has been closed for replies.

1 reply

Brainiac
February 26, 2013

Check your quotes around Hello World...

Jim Leichliter

February 26, 2013

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 ?

February 27, 2013

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!


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.