Javascript photo pop out not working, yet script works fine

simbob

New Member
Hi, i have a problem getting a Javascript photo pop up widget called 'ClearBox' to run. I've used this
before on other sites and it works fine, i've even copied all of the necessary elements into a new file and it works fine there, so there must be something in my page code or HTML that is stopping it working, there several other JS scripts in this page (as well as php) all working correctly, but i'm not sure whether any of these could be interfering, i don't know enough about JS to identify the problem, here's my page (thought i post a link rather than past the whole page content in here):

http://www.fogi-design.co.uk/fogi_portfolio.php


Problem Solved - Moved the JS script from the <head> to the bottom of the <body> and has solved the problem.
 
Last edited:

notarypublic

New Member
Do you understand why that 'fix' has worked?

To expand on chrishirt's question:

It's hard to know without looking at what your code looked like before, but the location of a plug-in can matter in regard to other javascript on the page. I looked at the plug-in you're using's code, and I believe I have the answer:

Think of the web browser as reading HTML like a recipe. It starts at the top of the document, and follows all the instructions in the order that it's written inside the document. This means that if a JavaScript code is at the top of the document, it is read (and obeyed) before the browser reads the <body> part of the HTML page.

A lot of times, you don't want javascript to run until after the page has finished loading. This is one reason why putting a javascript file at the bottom of the page will work, if it doesn't work at the top.

Here is a good resource for learning more about javascript (which I highly recommend! It is a great skill to have). codecademy.com

Also, what CMS are you using?
 

chrishirst

Well-Known Member
Staff member
Yes but the idea was to see if jimbob knew why and therefore had learnt something along the way rather than it being a lucky fluke.
 
Top