0
我在index.html中有一个文本框,我想获取它的值并将其放到另一个html文件result.html中的文本框中。 (他们使用相同的.js文件)获取文本框的值到另一个html文件
index.html的文本框:
<input id="txt2" readonly="true" type="number" value="0" name="score" style="border:none;background-color:#f0f2f7">
result.html文本框:
<input id="txt3" readonly="true" type="number" value="0" name="score" style="border:none;background-color:#f0f2f7"></td>
这是代码它会自动转到其他页面:
if((mins == 0) && (secs == 0)) {
//window.alert("Time is up.Your score is "+score); // change timeout message as required
document.getElementById('txt2').value = score;
window.location = "score.html" // redirects to specified page once timer ends and ok button is pressed
}
else {
cd = setTimeout("redo()",1000);
}
txt3如何获得txt2的值,因为它们在不同的html?
在此先感谢。
如果你有通过这个值横跨你可能想使用cookie来使所有网页的数据持久化尝试没有服务器端的帮助。 – Lix
或研究html5功能。我认为这有点像本地存储。这可能是你正在寻找,可能也完全不符合... –
@MAXIMUM请考虑绿色检查答案,如果答案服务你的目的。更多详细信息在这里如何做到这一点http://meta.stackexchange。 COM /问题/ 23138 /如何对接受-的回答上堆栈溢出 –