在我的Javascript代码中我有一个无限循环,点击一个按钮,从几个文本框收集值并将它们发送到PHP脚本。我不知道如何做到这一点,但打开PHP脚本的新窗口。一切都在本地主机上运行。所以我的代码看起来像这样:Javascript页面在打开新窗口后停止响应
<body onload="generator();">
...
function generator(){
phpWindow = window.open("http://localhost/adressSaver.php", "", "width=200, height=100");
while(true){
document.getElementById("genRandom").click();
var first = document.getElementById("first").value;
var second = document.getElementById("second").value;
phpWindow.location = "http://localhost/adressSaver.php?first=" + first + "&second=" + second;
}
}
我认为使用这个,每个周期变量将被传递给PHP脚本。但是,相反,当我打开这个文档时,会创建一个PHP的新窗口,然后这两个窗口永远不会加载任何内容。我甚至试图取消循环,并使其成为一次性操作,没有变化。 任何想法?
感谢
谢谢你的回应。现在主窗口加载正常,但phpWindow加载并保持空闲状态,传递变量的重定向不起作用,请问您可以帮我吗? –
我的错误,10毫秒太短,尝试了100,现在工作正常。谢谢! –