Hi Diego,

in my test cases your example does not work.
At the same time, I am not sure you have to put the image in the DOM, before
the event could be called.

If you need to do it, the evaluation will be async, so as globalEval
replacement, it is not that good.

If not, you are still evaluating "whatever" inside a function and, as you
know, this simply means that if you have a global scope variable, called
arguments, you will never be able to use it as is, unless you specify the
global object as prefix (window or self, because this will be the image
itself)

I wonder why you are still looking for a globalEval alternative. What I mean
is: which kind of problem has the current solution?

I would like to know it and try to fix it, if it is possible, since "I feel
a bit responsible" for that code :-)

Regards

On Thu, Sep 18, 2008 at 1:23 AM, Diego Perini <[EMAIL PROTECTED]>wrote:

>
> Hi devs,
> would like to leave a note on this, seem interesting and maybe can be
> used as an alternative to globalEval.
>
> It turns out that we have another way to evaluate javascript strings
> easily, namely by using setAttribute() to assign a string value to
> some specific attribute like the DOM 0 (or in-line) event.
>
> So, at first I tried using the standard body "onload" attribute, but I
> in IE that didn't work as in FF.
>
> Then I did some test with an image and that worked both in FF and in
> IE (believe it works in other browsers too).
>
> var img = document.createElement('img'); // or just new Image();
> img.setAttribute("onabort", "function () {}"); // onerror, onload also
> works
> alert(typeof img.onload); // yeld function instead of string...good.
>
> I was thinking to this while thinking to Air, Caja and similars.
>
> Evil...good...useful ?
>
> Your thoughts appreciated.
>
> --
> Diego Perini
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to