Search code examples
jqueryvideomootools

show Videobox on document.ready


Now according to the author's site i should be able to load videobox on document ready by just calling it like this:

Videobox.open("your video page url","your caption","vidbox width height");

but I keep getting this error:

Uncaught TypeError: Cannot call method 'setStyles' of undefined
   Videobox.positionvideobox.js:75
   Videobox.openvideobox.js:55
   (anonymous function)opcion2.html:13

this is being tested in Chrome

here's my code it's just simple cause I'm testing this functionality:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title></title>
     <link rel="stylesheet" href="css/videobox.css" type="text/css" media="screen" />   

     <script type="text/javascript" src="js/mootools.js"></script>
     <script type="text/javascript" src="js/swfobject.js"></script>
     <script type="text/javascript" src="js/videobox.js"></script>
     <script language="javascript">
          Videobox.open('http://www.youtube.com/watch?v=VhtIydTmOVU', 'Test', 'vidbox 979 416');

     </script>

   </head>

   <body>

   </body>
 </html>

Solution

  • You need to put that in a document.ready handler:

    $(function() {
        Videobox.open("your video page url","your caption","vidbox width height");
    });
    

    Or just move your original script section that made this call to the end of your body


    The author's site just says:

    You can also start your videos with javascript.

    Videobox.open("your video page url","your caption","vidbox widht height");
    

    He never said you could call this before your dom was ready.