这样写可以正常跳转:
<code>echo "<script>"; echo "window.location.href = '$url'"; echo "</script>";</code>
而下面代码服务器返回空白页面,没有执行我的命令,请问是怎么回事?php小白,照葫芦画瓢写的代码:
<code>echo "<script>"; echo "function() { alert($error_msg); setTimeout(window.location.href = '$url',5); }"; echo "</script>"; </code>
这样写可以正常跳转:
<code>echo "<script>"; echo "window.location.href = '$url'"; echo "</script>";</code>
而下面代码服务器返回空白页面,没有执行我的命令,请问是怎么回事?php小白,照葫芦画瓢写的代码:
<code>echo "<script>"; echo "function() { alert($error_msg); setTimeout(window.location.href = '$url',5); }"; echo "</script>"; </code>
setTimeout(func,5);
前面func是一个方法
<code>echo "<script>"; echo "function func() { alert($error_msg); window.location.href = '$url'; }"; setTimeout(func,5); echo "</script>";</code>
楼上仁兄正解
<code><?php $url = "http://www.baidu.com"; $error_msg = "error"; echo "<script>"; echo "function jump() { alert('$error_msg'); window.location.href = '$url'; } setTimeout(jump, 3000); "; echo "</script>";</code>
你js部分只是定义了函数没有调用啊