[英]How to pass value to previous html page
我有一个带有文本框的HTML页面。 在单击文本框时,将显示一个弹出窗口,在单击“确定”按钮后,该弹出窗口必须关闭,并且第一个HTML页面中的文本框必须填充第二个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中
<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
<input type="button" onclick="settoparent()" />
<script type="javascript">
function settoparent()
{
if(window.opener.setvalue!=undefined)
{
setvalue("textboxvaluefromHTML2");
}
window.close()
}
</script>
你必须用
window.opener.$("#yourtextfieldid").val(value);
为达到这个
在您的Vanila JS中
window.opener.document.yourelementID.fieldname.value="Any value";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.