If none of the above work...

document.write('<script type="text/javascript" src="'
http://somewhere/edu/is//prototype.js";><\/script>');

have you tried removing the extra "/" before "prototype.js"?







On Fri, Sep 18, 2009 at 1:45 PM, Ngan Pham <nganp...@gmail.com> wrote:

> Hi jrochkind,
> I believe document.write is execute properly and full before your observe
> call is done.  However, document.write's job is simply to write the string
> to the browser, nothing more.  It's then the browser's job to interpret the
> string and do whatever it has to do on a different tangent. In this case,
> load an external javascript document.  So immediately after document.write
> has performed it's job, the next statement is ran--which causes the problem
> for you since the external prototype script is not ready.
>
> As stated above this isn't a good thing to do in general.  However, to
> answer your question....you either of the follow (there may be more
> options):
> 1. Modify the prototype.js file and add a function call at the bottom to
> let your page know prototype is loaded.
> 2. Use a setInterval function to periodically check for prototype's
> existence.  Once it's available you can then stop the checking and resume
> your code.
>
> On Thu, Sep 17, 2009 at 12:37 PM, Jonathan Rochkind <rochk...@jhu.edu>wrote:
>
>>
>> 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