David said:
[...]
Creating a bunch of non-standard "dummy" elements and then
going through all of the mess of positioning them
That can be done in a few lines of code with a reasonable position
function. The one at Javascript Toolbox seems to do the job OK.
That is an oversimplification. Even if you just consider the major
browsers in standards mode, there are many quirks and bugs to deal
with.
I looked at the one in JavaScript Toolbox and it is inadequate.
There's not a single feature test, though there is one browser sniff
(an inference from the opera object.)
I posted the link as an example, I'm not saying it's a perfect library -
there isn't one. But Matt's is as good at what it does as any other
I've stumbled across, and much better than most.
I agree that most positioning snippets are useless, but didn't see
that one as much better.
You will not find a position library, anywhere, that works for every
browser and every situation (even if "every" is browsers since IE/NN 4).
The script I use works for virtually everything that matters, though I
certainly haven't tested with NN 4 (which doesn't matter.) My point
is that the one posted won't even work properly in the latest version
of Opera in standards mode.
It only needs to work to the extent that a drag library does, and that
is likely even more limited.
How so?
A drag library is probably more dependent on accurate positioning than
the suggested select hiding script.
The drop portion of the lib has to do the same thing (find the
absolute position of an element.)
Which will affect the drag library too. It should probably use the same
That depends on how it stacks up to the posted positioning script. If
it has the same limitations then it will break.
position functions as whatever is used to place the iFrames. I've
already agreed that my original solution is a poor one, so this is all
theoretical now.
It takes a bit of messing around to get rid of the borders.
<URL:
http://forums.devshed.com/css-help-116/iframe-border-problems-css-ie-...
Too complicated to keep two objects, both controlled by the same script,
the same size and position? If you can't do it with two, you can't do
it with one either - in which case there's no need for the second.
I don't follow you there. My point is that it is easy to break with
style changes. Introducing script to handle this situation makes for
a more complicated solution.
We are talking about dragging DOM objects around and repositioning them
on the page (and maybe within the DOM), I think it's a bit coy to say
you can't handle adding a single extra element temporarily to the DOM.
My problem is with adding, positioning and sizing a non-standard
IFrame to the DOM as a workaround when you could just set the
visibility style of the form elements.
The entire page is at your command, you aren't trying to drag some
Until it is passed on to another person to maintain. If the next
owner adds a border to the drag panel or HTML or whatever, they will
likely break the workaround. I am not saying it is impossible to make
the script(s) robust enough to handle such a change, but that it is a
lot more work than hiding elements.
random object in a totally unknown environment. If you are going to try
and write a drag library that works in every browser for every possible
situation, it *will* fail in places. I think everyone who writes such
libraries accepts that.
The drag part shouldn't fail, even in IE4. The drop part needs to use
robust positioning code if it is to work in even the latest versions
of major browsers in standards mode. Most positioning snippets on the
Web are inadequate for this.
That is a QC issue common to every bit of code every written, it is not
exclusive to web page authoring.
My point is that positioning code is complex and susceptible to minor
CSS changes.
There are a lot of scripts being written that are utterly dependent on a
precise DOM order, mostly encouraged by script libraries that encourage
walking the DOM with functions like 'up', 'next' and 'previous'. Insert
a single extra element into those and see what happens.
Lots of people write and post bad scripts. I wouldn't use or
recommend them. In the case at hand, I disagree with the
recommendation to use a script that is easy to break in favor of a few
lines of code that will never break.
But not all browsers do, though likely more support CSS than the drag
and drop stuff the OP is attempting to implement.
The browsers that do not support CSS will not support drag and drop.
If you can't drag the panel, you don't need to hide the form
elements. The drag lib the OP is using probably doesn't take this
into account, so you would need to test for CSS support in your hiding
code.
if (el.style) { el.style.visibility = 'hidden'; }
If I were using a third-party drag script, I would do something like
this before passing the panel to it.
if (el.style && typeof(el.style.position) == 'string') ...
If that fails, drag and drop is not initialized and the hiding code
will never called.