读书人

eval火狐报错该如何做

发布时间: 2012-04-28 11:49:53 作者: rapoo

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()

读书人网 >JavaScript

热点推荐