Loony2nz a écrit :> ==========================================> <script
type="text/javascript">
> function getUpdateInfo(e) {
> left =
parseInt(Element.getStyle(e,''left'').replace(''px'',''''));
> top =
parseInt(Element.getStyle(e,''top'').replace(''px'',''''));
> alert("top: " + top + "\n" + "left:" + left
);
> }
> </script>
>
> <div id="blah" style="margin-left:200px;margin-top:200px;
border:1px
> solid black; width:200px;height: 200px;"
> onclick="getUpdateInfo(this.id)">Click me!!</div>
> <script type="text/javascript">
> new Draggable(''blah'',{
> revert: false,
> endeffect:function(e){
> getUpdateInfo($(e).id);}
> });
> </script>
> ========================================> this line:
>
> top =
parseInt(Element.getStyle(e,''top'').replace(''px'',''''));
>
> IE6 barfs. Been banging my head on this for 2 hours...ugh!
What do you mean by "IE6 barfs"? I seem to recollect the getStyle on
IE
returns only specified/literal values, not computed values. Since your
style on the elements never specifies the left and top property (plus,
you div doesn''t appear to be positioned: it''s neither
relative, nor
absolute, nor fixed), this may be the trouble: getStyle would return
undefined, and I''m sure calling parseInt with what amounts to no
argument would raise a problem.
http://prototypejs.org/api/element/methods/getStyle
I have no IE6 to test things out just now, but a quick advice: why the
hell do you go from element reference to ID, only to use the ID again to
fetch its element reference? In the first call (on your DIV), use
getUpdateInfo(this). In the second one (Draggable), use
getUpdateInfo(e). That avoids a roundabout trip.
Also, there''s no need for the replace call on strings: parseInt will
automatically ignore trailing garbage on your string argument.
--
Christophe Porteneuve a.k.a. TDD
"[They] did not know it was impossible, so they did it." --Mark Twain
Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---