|
Posted by db on 06/19/06 14:34
Hi, thanks man,
With removing the weird setAttribute method, it works now under IE. I
dont know why the javascirpt ppl wrote these stuffs whereas they can
not work!
Thanks a lot!
I searched somehow in internet, and got these information, maybe that
will be helpful for someone who has the same problem as me:
> >> // we want an onclick on this button for
> >> example
> >
> > field.onclick = functionName;
> >
> > Don't use setAttribute and getAttribute, except when there is no other
>way
> > to do what you want to do.
>
>I wouldn't go that far, since the W3C DOM prescribes
>setAttribute()/getAttribute() as the way to write/read attribute values.
True, but in practice I found that many problems can be avoided by
avoiding
set/getAttribute when possible. It's about the only more or less
general
rule I found for using the W3C DOM, so I repeat it whenever I have the
chance.
>That said, setAttribute() doesn't work for event handlers in IE (Win/Mac).
>For some reason IE doesn't resolve the value to the function object, so
>nothing happens at event time.
Well well, interesting. I didn't know that.
>It does work in Mozilla, however, and can be
>beneficial in some cases: creating an event handler call that passes
>arguments consisting of values assembled in the script setting the
>attribute (rather than relying on the event object's properties for
>details).
I hadn't thought of that.
>In any case, to assign (or reassign) an event handler on the fly, event
>handler property assignment, as shown above, is the way to go if you need
>to serve IE in your audience browser mix.
<plug type="shameless">
On my W3C DOM mailing list (http://www.xs4all.nl/~ppk/js/list.html) we
often
discuss problems like this one. Event handler registration, especially,
turns out to be a rather problematical area with many small browser
problems.
If you're interested in getting the DOM to work in all browsers you
might
consider joining the list, as many JavaScript developers have done
before
you.
Navigation:
[Reply to this message]
|