如果我通过AJAX发送一个header()到javascript,然后使用文档写输出。写,将启动javascript的onload函数,如果文档。写写整个页面?我需要它初始化
真正的问题是document.write
在初始DOM加载后是否会重新调用文档的onLoad
函数。
可简单测试,答案是"否":
$(function() {
document.write("lol");
// ^ interestingly, `console` doesn't appear to exist after this
alert("onload"); // only happens once
});
不会的。然而,你应该防止在调用header("Location: something.php");
你可以用
die();