Hi Mislav,

The point of the iframe hack is to trigger the onload event. The js
code won't be executed there in any way ; it is executed as in the
other browsers, when the <script> element is inserted. as the <iframe>
and the <script> point to the same file, they "should" be loaded at
the same time. At least that is the behaviour I get in safari when
loading some slow scripts (see test below)

The hack is included because despite a few hours of research I
couldn't find any way to trigger any event in Safari when a script is
loaded. I couldn't either find a property of the script element that
changes after the script is loaded. Maybe there could be an exception
that is only triggered when a script is not yet loaded when altering
an attribute?

The bug is here but I think it needs some love:
http://bugs.webkit.org/show_bug.cgi?id=12131

Happens with the nightlies too.


I have a test class for it:


                //used in delay switch and testInsertScript
                var myVar = 0;

                //used in testInsertScript
                var callback = function(argument) {
                        myVar = argument;
                }

          new Test.Unit.Runner({

            testInsertScript:function() {
                var t = this;

                //test without callback
                Prototype.insertScript("fixtures/callback.js?_="+Math.random());

                t.wait(2000,function() {

                        t.assertEqual("Iñtërnâtiônàlizætiøn",myVar,"no 
callback");

                        //test with explicit callback
                        var id2 = Prototype.insertScript("/
sleep.php&_="+Math.random(),function() {
                                callback("Iñtërnâtiônàlizætiøn 2");
                        });

                        t.assertEqual("Iñtërnâtiônàlizætiøn",myVar,"zero");

                        t.wait(2500,function() {

                                
t.assertEqual("Iñtërnâtiônàlizætiøn",myVar,"first");

                                t.wait(4000,function() {

                                        t.assertEqual("Iñtërnâtiônàlizætiøn 
2",myVar,"second");
                                });

                        });

                });



            }

        });




callback.js :

setTimeout(function() {
        callback("Iñtërnâtiônàlizætiøn");
},1000);


sleep.php :

sleep(5);
echo "1;";


On May 19, 2:26 am, "Mislav Marohnić" <[EMAIL PROTECTED]>
wrote:
> On 5/19/07, Tobie Langel <[EMAIL PROTECTED]> wrote:
>
>
>
> > I think Sylvain is just using the iframe to get an onload event
> > triggered.
>
> I get it too, but what of the script? When you dynamically load JS you want
> it to be executed - that is the whole point of the dynamic script tag.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to