If you have the following message error in ErrorShell (among others ;) )
element.dispatchEvent is not a function
while you are using (or trying) LightBox or one of his clones with Scriptaculous libraries, one solution of your problem could be to check that your Lightbox javascript file is not call before some Jquery’s…
Let’s take a totally random example from my website:
<script src="/js/prototype.js" type="text/javascript"> </script>
<script src="/js/scriptaculous.js?load=effects" type="text/javascript"> </script>
<script src="/js/lightbox.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
Doesn’t work because… Jquery’s files are cancelling the window.onload function !
So two ideas:
– Move or Lightbox’s links after the Jquery’s ones. Like that:<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
<script src="/js/prototype.js" type="text/javascript"> </script>
<script src="/js/scriptaculous.js?load=effects" type="text/javascript"> </script>
<script src="/js/lightbox.js" type="text/javascript"></script>
– Rewrite the Event observer from lightbox.js in after Jquery’s links. Like that:<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
Event.observe(window,'load',function(){ Lightbox.initialize(); });
Hope it helps. Have fun with Lightbox !
- La Horde du Contrevent : review - 13 October 2024
- For Whom the Bells Tolls: review - 4 August 2024
- Self Aware On Air Neon Sign - 8 June 2024
fanx :)
awesome! Thanks
Hi mate, your blog’s design is easy and clean and i like it. Your blog posts are fantastic. Please hold them coming. Greets!!!!
thanks, it helped a lot!
i had try this but as footer containing the jquery if i write Event.observe(window,’load’,function(){ Lightbox.initialize(); });
after including the footer file it will throws 2 errors:
element.attachEvent is not a function in prototype.js (line 3917)
element.dispatchEvent is not a function in prototype.js (line 3972)
can any one help me?
Thanks in Advance.
@mitali it seems that your Lightbox is requiring prototype.js (and the lib is missing, you should include it before) instead of jQuery…
Hi @Fabien,
Great post! It worked for me.
Thanks.