child box id

Page: 1

Author Post
smarten
Guest
Hi,

Quick question, apologies if this has been covered already, or I'm doing something wrong

I am using floatbox to launch a flash file, then launch another child flash file on top of that.

I noticed that the main floatbox and launched child floatbox have the same ids (as well as all their corresponding children). Is this not likely to be a problem?

awesome software btw.
Administrator
Registered: Aug 2008
Posts: 3382
You're the first one to catch the fact that multiple floatboxes result in multiple elements with the same ID. Congratulations. Sorry, there is no prize. :(

The multiple IDs are a technical violation of the html spec, but the way the IDs are used means there are no problems associated with this violation. The only thing floatbox element IDs are used for is assigning css properties to those elements. All browsers correctly assign css properties to all elements with the given ID. Problems would occur if the floatbox code tried to get references to the elements using getElementById() or a similar library derivative, but floatbox does not this. It keeps pointers to all its elements that are assigned when those elements are created and always uses those pointers when referencing.

The multiple IDs arise from a combination of history and choice. Earlier versions of floatbox didn't support multiple boxes being loaded and so the IDs were always unique. When multiple boxes came on stream I considered switching from IDs to classes but chose not to for two reasons. The first was that there were no problems in any browsers from keeping the ID scheme and I didn't want to spend time fixing what was not broken. The more important reason was that ID references in css files have much greater specificity than class references. I need to keep specificity maximized in floatbox.css otherwise some folks run into problems with floatbox breaking due to their site's css files over-riding style assignments being made through floatbox.css.

Bottom line: no, not likely to be a problem.
smarten
Guest
Bummer about there not being a prize :lol:

I didn't mean to be picky, was just trying to see if I was doing something wrong. My problem is that I have two floatboxes, and need to access the child box, to stop a video playing when it's closed. I'll work around it.
Administrator
Registered: Aug 2008
Posts: 3382
There's lots of variables available that give access to the different boxes. fb always points to the first (bottom) box. fb.lastChild always points to the last loaded (top) box. fb.fbParent points to the second-to-last loaded box, or the middle one if you've got three open. So, for example, fb.lastChild.fbContent gives you the content div, img, or iframe element (depending on content type) of the top box.

If you've direct-loaded flash or quicktime in floatbox, and you have only one such object loaded, top.document.getElementById('fbObject') will get that flash object. If you've got multiple flash objects running in multiple boxes, it's probably best to load the one you're interested in as an iframe rather than direct load, and access it by unique assigned id from the iframe window.

To get the document object of an iframe loaded in the last floatbox of two, you can use:
var node = fb.lastChild.fbContent;
var idoc = node.contentDocument || node.contentWindow; // iframe's document, or maybe its window
idoc = idoc.document || idoc; // now it's the doc for sure

After that, idoc.getElementById('xyz'); gets the element inside the floatboxed iframe.

Hope this helps...
smarten
Guest
Thanks for that, sounds like a plan.

Page: 1