> Would somebody know that why if the 1st and 2nd line is swapped, then
> Firefox 2 and IE 7 will not run...

As Justin said, if it loads fast enough (such as from cache), the
event will get fired before your doc has been fully loaded and before
the script exists.  Remember that unless you use a load handler
(either window.onload or Prototype's own "dom:loaded" events), things
early in the page can happen before the page as a whole exists in the
browser.

> also, I thought it is said that to guarantee that node.getWidth() can
> return something, it needs to be  $(node).getWidth() so that node
> becomes the "extended element"...  but it is not needed in the code
> and it still runs?

Depends on what browser you're using. The joy of documentation:
http://www.prototypejs.org/learn/extensions

Hope this helps,
--
T.J. Crowder
tj / crowder software / com

On Apr 25, 6:42 pm, liketofindoutwhy <[EMAIL PROTECTED]>
wrote:
> Would somebody know that why if the 1st and 2nd line is swapped, then
> Firefox 2 and IE 7 will not run... Firefox shows "ShowMe is not
> defined"... and Safari runs it without any problem.
>
> also, I thought it is said that to guarantee that node.getWidth() can
> return something, it needs to be  $(node).getWidth() so that node
> becomes the "extended element"...  but it is not needed in the code
> and it still runs?  How can prototype make it extended element
> automatically?
>
> Also related is that... does someone know how come offsetWidth is well
> documented in the Definitive Javascript book while clientWidth and
> scrollWidth are not?  even though all 3 works in all Firefox, IE, and
> Safari.  Thanks very much!
>
> <script src="prototype.js"></script>
>
> <a href="http://www.google.com";><img id="theimg" 
> src="http://www.sanrio.co.jp/english/characters/w_chara/pocha180.gif";
> onload="showMe(this)"></a>
>
> <script>
> function showMe(node) {
>     document.getElementById("display").innerHTML = "Offset " +
> node.offsetWidth + " x " + node.offsetHeight + "<br>" +
>         "Client " + node.clientWidth + " x " + node.clientHeight +
> "<br>" +
>         "Scroll " + node.scrollWidth + " x " + node.scrollHeight +
> "<br>" +
>         "Prototype " + node.getWidth() + " x " + node.getHeight()
>
> }
>
> </script>
>
> <div id="display"></div>
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to