在第一页中,我在文本框中获取值,我需要将其传递到另一个页面,该页面分为 2 个框架。
我需要在第一帧的 html 页面中显示该值。
请给我一个简单的例子。
我尝试过
window.document.getElementById("inputbox1").value
但我无法获得价值。
请给我一个简单的例子。
我会使用 localStorage,正如 @MicrosoftGoogle 所建议的那样,但还没有得到很好的支持,您可以使用纯 javascript 来实现这一点。您的表单页面上将会有类似这样的内容:
<form action="param-received.html" method="GET">
<input type="text" id="foo" name="foo">
<input type="submit" value="Send" name="submit" id="submit">
</form>
单击“发送”按钮后,您将被重定向到/param-received.html?foo=hola&submit=Send
.
-
location.search
属性包含参数链。
- ?连接 URL 和参数字符串。
- & 分隔多个参数。
- = 为变量赋值。
这是处理发送的数据的完整代码param-received.html
:
<script language="JavaScript">
function processForm()
{
var parameters = location.search.substring(1).split("&");
var temp = parameters[0].split("=");
l = unescape(temp[1]);
alert(l); //Dialog with the text you put on the textbox
}
processForm();
</script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)