/    Sign up×
Community /Pin to ProfileBookmark

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:

[COLOR=”Blue”]
<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>[/COLOR]

the script should output :
[COLOR=”Blue”]200
123
27 [/COLOR]

yet on chrome it only outputs
[COLOR=”Blue”]200[/COLOR]

much regards for the help

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@cluefulMay 28.2011 — 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})()") );[/CODE]
Copy linkTweet thisAlerts:
@rnd_meMay 31.2011 — statements are greedy but easily coercible into leaky expressions: [CODE]eval("[COLOR="Red"]0||[/COLOR]function(){var loop='123';return loop}")()[/CODE]
×

Success!

Help @degreane spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...