Why not attach the widget code to dom:ready....

Alex Mcauley
http://www.thevacancymarket.com
----- Original Message ----- 
From: "JoJo" <tokyot...@gmail.com>
To: "Prototype & script.aculo.us" <prototype-scriptaculous@googlegroups.com>
Sent: Tuesday, December 15, 2009 8:57 PM
Subject: [Proto-Scripty] Firefox's inline JS execution order


> I'm creating a widget where I tell people to copy and paste this code
> onto their site:
>
>   <script type="text/javscript" src="http://www.site.com/script.js";></
> script>
>   <div class="widget"></div>
>
> Script.js looks for all the widget divs on the page by using $$ and
> dynamically fills them up.  Now, I'm not catering to nerd programmers
> who know that it's better to do this when they need to embed multiple
> widgets:
>
>   <head>
>      <script>
>   </head>
>   <body>
>      <div class="widget"></div>
>      <div class="widget"></div>
>      <div class="widget"></div>
>   </body>
>
> Instead, I'm expecting stupid people to be doing this:
>
>   <body>
>      <script>
>      <div class="widget"></div>
>      <script>
>      <div class="widget"></div>
>      <script>
>      <div class="widget"></div>
>   </body>
>
> So I've tried to only execute my script once using:
>
>   if (typeof(RAN_ONCE) === 'undefined') {
>      RAN_ONCE = true;
>      // minified Prototype code here
>      // minified my widget code here
>   }
>
> This code works well in IE, but not in FF. FF always reports an error
> saying $A is undefined. I'm guessing that FF actually ran my code in
> parellel and thus Prototype got redefined and screwed up?  Does anyone
> know how execution order is different in IE and FF with inline JS?
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Prototype & script.aculo.us" group.
> To post to this group, send email to 
> prototype-scriptacul...@googlegroups.com.
> To unsubscribe from this group, send email to 
> prototype-scriptaculous+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
>
> 

--

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.


Reply via email to