Shadowbox Loading Problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Shadowbox Loading Problem

DFC005
Hey!

I'm having a problem using the default onload found on http://mjijackson.com/shadowbox.


<link rel="stylesheet" type="text/css" href="global/css_shadowbox.css">
<script type="text/javascript" src="global/js_yui-utilities.js"></script><script type="text/javascript" src="global/js_shadowbox-yui.js"></script><script type="text/javascript" src="global/js_shadowbox.js"></script><script type="text/javascript"> YAHOO.util.Event.onDOMReady(function() { Shadowbox.init(); }); </script>

If a user clicks on the link too quickly, they get the target page rather than it loading in a shadowbox.
Reply | Threaded
Open this post in threaded view
|

Re: Shadowbox Loading Problem

Wizzud
There is little you can do about this. The document has be at a stage where all the relevant links are present, otherwise the script can't find them and therefore can't set them up for shadowbox. The whole point of the various 'DOM Ready' techniques is to attempt to run a script at the earliest possible time when the document should be fully populated with all elements that might be targeted by that script. If you run without the 'DOM Ready' (or window.onload, whatever) then your page elements probably won't have been placed in the DOM and therefore won't be picked up by the shadowbox intialisation.

One possible recourse is to not display the links until shadowbox has initialised (css display:none or visibility:hidden). However, this would mean that anyone visiting your site with javascript turned off would not even see the links, let alone be able to click on them. Also, until the shadowbox had initialised, the page would either have 'holes' in it where the links will suddenly appear (visibility:hidden), or it will suddenly readjust itself to bring the links into the document flow (display:none).

Or, you could put an onclick on every relevant link, that effectively disables that link.

Either way, you need to be able to show the links, or remove the onclicks, once shadowbox has initialised (or if it fails to initialise for whatever reason).
A third possibility might be to investigate the other libraries and see if any one out-performs the others in terms of 'DOM Readiness' (or maybe even window.onload ... but I doubt it very, very much!), but I'm not sure that you'll be able to find much of a difference.

I would suggest that it is probably better for any over-eager user to miss out on a fancy effect (of which you might justifiably be rather proud), but still end up seeing the content you want them to see ... rather than be frustrated by being told they can't click certain links yet, or put off by having extra links suddenly appear all over the page.
Combine literacy with curiosity and a whole world of information opens up to you