#99 ✓duplicate
tsveg1

scripts not eval in the global scope

Reported by tsveg1 | August 25th, 2008 @ 08:09 AM | in 1.7

The problem is in an AjaxRequest Call. In the evalScript Function javascripts are evaluated locally and not on the page (DOM). If I've got same new script in Response they are not correctly evaluated.

evalScripts: function() {

return this.extractScripts().map(function(script) { return eval(script) });

Suppose I define a new variable script (var dummy = 10). This code doesn't work because the script is not evaluated on the dom (an example is popup component in tomahawk jsf component).

The possible correction is:

evalScripts: function() {

return this.extractScripts().map(
    function(script)
    {
      try {
        if (window.execScript) { // Eval correctly in IE                return window.execScript(script);
    } else {  // Eval correctly in FF
        return window.eval(script);
    }
          } catch (e)
          {}
      }
);

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket

Pages