By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 1,962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Get rid of 'eval'

P: n/a
This is a question to those who mean 'eval is evil'. I'm one of those.
However, I cannot answer my question. ;-)

Have a look at this page

http://home.arcor.de/pil/show-gallery.html?p=clouds

You'll notice that a parameter is passed through the URL. This is
necessary to choose the appropriate picture category. Therefore there
are three or four 'eval' inside the script.

The question is: How can this be done without 'eval'?

Oct 6 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Mon, 6 Oct 2008 08:57:06 -0700 (PDT), /Proper/:
Have a look at this page

http://home.arcor.de/pil/show-gallery.html?p=clouds

You'll notice that a parameter is passed through the URL. This is
necessary to choose the appropriate picture category. Therefore there
are three or four 'eval' inside the script.

The question is: How can this be done without 'eval'?
eval('pics.'+ category +'.length') == pics[category].length

eval('pics.'+ category +'[nr].path') == pics[category][nr].path

--
Stanimir
Oct 6 '08 #2

P: n/a
Stanimir Stamenkov wrote:
Mon, 6 Oct 2008 08:57:06 -0700 (PDT), /Proper/:
>Have a look at this page

http://home.arcor.de/pil/show-gallery.html?p=clouds

You'll notice that a parameter is passed through the URL. This is
necessary to choose the appropriate picture category. Therefore there
are three or four 'eval' inside the script.

The question is: How can this be done without 'eval'?

eval('pics.'+ category +'.length') == pics[category].length

eval('pics.'+ category +'[nr].path') == pics[category][nr].path
Right.

The question is also answered in the FAQ:
http://jibbering.com/faq/#propertyAccess
http://jibbering.com/faq/#eval

Also see:
http://www.jibbering.com/faq/faq_not..._brackets.html
Oct 7 '08 #3

P: n/a
On Oct 7, 4:36 am, dhtml wrote:
<snip>
The question is also answered in the FAQ:
http://jibbering.com/faq/#propertyAccess
<snup ^^^^^^^^^^^^^^^

These fragment identifiers are non-functional in IE 6. As IE 6 is
still in common use you should either correct them so that they are
functional or abandon using them.
Oct 7 '08 #4

P: n/a
In comp.lang.javascript message <c3023857-d4bc-4b35-868c-39b544845219@f7
7g2000hsf.googlegroups.com>, Tue, 7 Oct 2008 02:46:43, Henry
<rc*******@raindrop.co.ukposted:
>On Oct 7, 4:36 am, dhtml wrote:
<snip>
>The question is also answered in the FAQ:
http://jibbering.com/faq/#propertyAccess
<snup ^^^^^^^^^^^^^^^

These fragment identifiers are non-functional in IE 6. As IE 6 is
still in common use you should either correct them so that they are
functional or abandon using them.
Would http://jibbering.com/faq/index.html#propertyAccess be
functional in IE6 etc.?; memory suggests yes.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.

Usenet News services are currently unreliable; I may not see all articles here.
Oct 7 '08 #5

P: n/a
On Oct 7, 5:36 am, dhtml <dhtmlkitc...@gmail.comwrote:
Also see:
http://www.jibbering.com/faq/faq_not..._brackets.html
Thanks guys, especially for this article
:-)

I'll leave my example from above untouched as an example for 'evil
eval'.
Oct 7 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.