Ô´ÂëÍø,Ô´ÂëÂÛ̳,Ô´ÂëÖ®¼Ò,ÉÌÒµÔ´Âë,ÓÎÏ·Ô´ÂëÏÂÔØ,discuz²å¼þ,ÆåÅÆÔ´ÂëÏÂÔØ,¾«Æ·Ô´ÂëÂÛ̳

 ÕÒ»ØÃÜÂë
 Á¢¼´×¢²á
Â¥Ö÷: ttx9n

[JavaScript] IE µ±evalÓöÉÏfunctionµÄ´¦Àí

[¸´ÖÆÁ´½Ó]

7Íò

Ö÷Ìâ

861

»ØÌû

32Íò

»ý·Ö

ÂÛ̳ԪÀÏ

Rank: 8Rank: 8

»ý·Ö
329525
·¢±íÓÚ 2011-8-9 20:47:03 | ÏÔʾȫ²¿Â¥²ã |ÔĶÁģʽ
ÔÚIEÏ£¬µ±evalÓöÉÏfunction£¬IEÏ»á³öÏÖ¹ÖÒìÇé¿ö£¬ÎÒÃÇÓÃÀý×ÓÒ»²½²½ËµÃ÷ Çé¿ö1£ºevalÀïûÓÐfunction£¬Ö±½ÓÖ´ÐУº
eval("alert('ss');");//ËùÓÐä¯ÀÀÆ÷ÕýÈ·¾ùÊä³ö
Çé¿ö2£ºevalÀïÓÐfunction£¬functionÁ¢¼´Ö´ÐУº
eval("(function(){alert('ss');})();");//ËùÓÐä¯ÀÀÆ÷ÕýÈ·Êä³ö
Çé¿ö3£ºevalÀïÓÐfunction£¬Ê¹ÓñäÁ¿±£´æfunctionÒýÓò¢µ÷ÓøÃfunction£º
var f=eval("(function(){alert('ss');})");
f();//IEϱ¨´í£ºÈ±ÉÙ¶ÔÏó ÆäËûä¯ÀÀÆ÷Õý³£
µ±ÔÚeval¶¨ÒåÒ»¸öfunction²¢·µ»Ø¸ø±äÁ¿Ê±£¬IE±¨´í£ºÈ±ÉÙ¶ÔÏ󡣿ɼûIEÏÂevalÀﶨÒåµÄfunction²¢²»Äܳɹ¦·µ»Øµ½evalÍⲿ¡£

½â¾ö·½·¨£ºÊ¹function¶ÔÏó×÷Ϊһ¸öÖ´Ðнá¹û·µ»Ø£º

·½·¨1£º

var f=eval("(function(){ return function(){alert('ss');}})()");
f();//ËùÓÐä¯ÀÀÆ÷ÕýÈ·Êä³ö
evalÀïµ÷ÓÃÒ»¸öÁ¢¼´Ö´Ðеĺ¯Êý£¬¸Ãº¯ÊýÖ´ÐÐÖ®ºó·µ»ØÒ»¸öfunction¶ÔÏ󣬴Ëʱ¸Ãfunction¶ÔÏóµÄÒýÓóɹ¦·µ»Øµ½Íⲿ±äÁ¿¡£

·½·¨2£º

var f=eval("(false||function(){alert('ss');})");
f();//ËùÓÐä¯ÀÀÆ÷³É¹¦Êä³ö
¸Ã·½·¨Ò²ÊÇjqueryÀïʹÓõķ½·¨£¬function×÷Ϊ»ò±í´ïʽµÄÖ´Ðнá¹û·µ»Ø£¬Í¬ÑùÄܳɹ¦½â¾öÎÊÌâ¡£µ±È»£¬±í´ïʽ²¢²»¾ÖÏÞÓÚÉÏÃæµÄfalse||function(){}£¬¸÷ÖÖ±í´ïʽֻҪÄܳɹ¦·µ»Øfunction£¬¾ù¿É½â¾öÎÊÌ⣺

/* Óë±í´ïʽ£º*/
var f=eval("(true&&function(){alert('ss');})");
f();//ËùÓÐä¯ÀÀÆ÷Õý³£Êä³ö

/* ÈýÔª±í´ïʽ£º*/
var f=eval("(true?function(){alert('ss');}:'');");
f();//ËùÓÐä¯ÀÀÆ÷Õý³£Êä³ö
»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

0

Ö÷Ìâ

1Íò

»ØÌû

68

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
68
·¢±íÓÚ 2022-11-4 16:41:48 | ÏÔʾȫ²¿Â¥²ã
À´¿´¿´£¡£¡£¡

0

Ö÷Ìâ

2Íò

»ØÌû

120

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
120
·¢±íÓÚ 2023-2-12 18:18:22 | ÏÔʾȫ²¿Â¥²ã
³é¸ùÑÌ£¬ÏÂÀ´¿´¿´ÔÙ˵

0

Ö÷Ìâ

2Íò

»ØÌû

66

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
66
·¢±íÓÚ 2023-11-28 07:41:29 | ÏÔʾȫ²¿Â¥²ã
ÓÐʲôºÃµÄ·þÎñÆ÷

1

Ö÷Ìâ

2Íò

»ØÌû

176

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
176
·¢±íÓÚ 2024-1-23 00:00:30 | ÏÔʾȫ²¿Â¥²ã
ºÜ²»´íµÄÔ´ÂëÂÛ̳

0

Ö÷Ìâ

1Íò

»ØÌû

68

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
68
·¢±íÓÚ 2024-4-12 14:56:20 | ÏÔʾȫ²¿Â¥²ã
À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²À²

0

Ö÷Ìâ

2Íò

»ØÌû

55

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
55
·¢±íÓÚ 2024-4-24 08:13:39 | ÏÔʾȫ²¿Â¥²ã
Ë¢ÆÁË¢ÆÁË¢ÆÁ

6

Ö÷Ìâ

2Íò

»ØÌû

425

»ý·Ö

Ö춻áÔ±

Rank: 3Rank: 3

»ý·Ö
425
·¢±íÓÚ 2024-4-26 16:31:43 | ÏÔʾȫ²¿Â¥²ã
Õâ¸öÔ´Â뻹¿ÉÒÔ

0

Ö÷Ìâ

2Íò

»ØÌû

124

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
124
·¢±íÓÚ 2024-6-23 17:49:38 | ÏÔʾȫ²¿Â¥²ã
ÎÒÒª½ð¶¹½ð¶¹½ð¶¹

12

Ö÷Ìâ

2Íò

»ØÌû

431

»ý·Ö

Ö춻áÔ±

Rank: 3Rank: 3

»ý·Ö
431
·¢±íÓÚ 2024-6-28 21:19:45 | ÏÔʾȫ²¿Â¥²ã
8888888888888888
¸ß¼¶Ä£Ê½
B Color Image Link Quote Code Smilies

±¾°æ»ý·Ö¹æÔò

ÊÖ»ú°æ|СºÚÎÝ|ÍøÕ¾µØͼ|Ô´ÂëÂÛ̳ ( º£Íâ°æ )

GMT+8, 2025-1-18 16:54 , Processed in 0.155670 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí