如何将值传递给以前的HTML页面 [英] How to pass value to previous html page
本文介绍了如何将值传递给以前的HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有文本框的HTML页面。点击文本框后,出现一个弹出窗口,点击确定按钮后,弹出窗口必须关闭,第一个HTML页面中的文本框必须填入第二个HTML中给出的值。
我尝试过这样的事情,
I have a HTML page with a textbox. On clicking the textbox, a pop-up shows up and upon clicking the OK button the pop-up has to close and the textbox in the first html page has to be filled with value given in the second HTML. I tried something like this,
one.html
one.html
<form name="form1" >
<input type="text" name="source" onclick="window.open('second.html')" />
</form>
second.html
<input type="button" onclick="{document.form1.source.value='hello';window.close()}" />
推荐答案
在您的first.html中
in your first.html
<form name="form1" >
<input type="text" id="txt1" name="source" onclick="window.open('second.html')" />
</form>
<script type="text/javascript" >
function setvalue(args)
{
document.getElementByid('txt1').value=args;
}
</script>
second.html
second.html
<input type="button" onclick="settoparent()" />
<script type="javascript">
function settoparent()
{
if(window.opener.setvalue!=undefined)
{
setvalue("textboxvaluefromHTML2");
}
window.close()
}
</script>
这篇关于如何将值传递给以前的HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文