日期:2014-05-16  浏览次数:20290 次

eval火狐报错,该怎么做
$str="function(){window.location.href='http://www.baidu.com'}";

然后 eval($str)()


出错了,,无法跳转,怎么做

------解决方案--------------------
$str = "window.location.href='http://www.baidu.com'";
eval($str);
------解决方案--------------------
多了一个()吧,去掉再调调看
------解决方案--------------------
$str="function(){window.location.href='http://www.baidu.com'}";

$str = eval('('+$str+')');
alert(typeof $str)
$str()
------解决方案--------------------
JScript code

$str="(function(){window.location.href='http://www.baidu.com'})";
eval($str)()

------解决方案--------------------
$str="void function(){window.location.href='http://www.baidu.com'}()";
 eval($str)
------解决方案--------------------
探讨

$str="function(){window.location.href='http://www.baidu.com'}";

$str = eval('('+$str+')');
alert(typeof $str)
$str()