Thanks Alex, I think that post does have the right analysis of what
was going on in my case and why it wasn't working.

And thanks for the alert that loading prototype via document.write in
general may be a bad idea.

Is there any good way to have an external .js file trigger a load of
Prototype, or is this basically just a lost cause, and if you want
Prototype on a page, you've just got to include a <script> tag that
references a prototype.js file directly on the page, no ifs and or
buts?

Jonathan

On Sep 17, 3:23 pm, Alexander Wallace <alexmlwall...@gmail.com> wrote:
> While I don't recommend loading prototype via document.write,
> this might be due to including both the doc.write(prototype) and the
> doc.observe() function within the same enclosing <script> tag.
> See:http://kossovsky.net/index.php/2009/07/script-as-blocking-element-and...
>
> But I really don't recommend loading prototype.js using document.write.
> I'm not sure how that would interfere with the IE method of dom:loaded
> (which involves using document.writing a deferred script element and
> watching its .onreadystatechange), but I can't imagine the outcome
> would be bug-free.
>
> -Alex
>
> On Thu, Sep 17, 2009 at 2:54 PM, jrochkind <rochk...@jhu.edu> wrote:
>
> > So theoretically (Prototype 1.6), it should be possible to have
> > javascript code include the Prototype library into a page via
> > document.write, right?
>
> > document.write('<script type="text/javascript" src="'http://somewhere/
> > edu/is//prototype.js"><\/script>');
>
> > Okay, this mostly works. Unless you want the same script that did this
> > to then immediately call any Prototype function, such as
> > document.observe.
>
> > document.write('<script type="text/javascript" src="'http://somewhere/
> > edu/is//prototype.js"><\/script>');
> > document.observe("dom:loaded", function() { alert('loaded!'); });
>
> > This does NOT work, because at the point that document.observe is up
> > there, Prototype is NOT actually loaded yet.  Although it will be
> > eventually.
>
> > Can anyone explain what's going on?  Does the browser not do or fully
> > process the document.write until after the current script is fully
> > done?
>
> > Is there any way to have a script include the prototype library
> > dynamically, and then have that same script call some prototype
> > functions, such as in particular document.observe?
--~--~---------~--~----~------------~-------~--~----~
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-scriptaculous@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