www.webdeveloper.com
Results 1 to 3 of 3

Thread: Eval works on FireFox but not on Google-Chrome

Hybrid View

  1. #1
    Join Date
    May 2011
    Posts
    1

    Unhappy Eval works on FireFox but not on Google-Chrome

    Good day guys.
    While doing simple interactive mathematical calculator for my son, i came across some issues. in the beginning i was working on Firefox 4.0.1 Fedora 15 didn't get any issue yet when i switched for google-chrome 11.0.696.68 the script didn't work anymore.
    i trimmed it down to simplest form possible and here i demonstrate:


    <html>
    <body>

    <script type="text/javascript">

    eval("x=10;y=20;document.write(x*y)");
    document.write("<br />" + eval("function(){var loop='123';return loop}")());
    document.write("<br />" + eval(x+17));

    </script>

    </body>
    </html>


    the script should output :
    200
    123
    27

    yet on chrome it only outputs
    200

    much regards for the help

  2. #2
    Join Date
    Dec 2010
    Posts
    207
    If you use Chrome's console you'll see the problem.

    If you must use eval, you can do this:
    Code:
    document.write("<br />" + eval("(function(){var loop='123';return loop})()") );


    Q: I found this code...
    A: Then find its author.

  3. #3
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    statements are greedy but easily coercible into leaky expressions:
    Code:
    eval("0||function(){var loop='123';return loop}")()

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles