注册 登录
编程论坛 ASP技术论坛

iframe 怎么传值到父窗口中的文本框中

guang2356447 发布于 2010-01-03 01:13, 2209 次点击
父窗口http://www.    里面有个iframe 点提交按后进入页面zp5save.asp  显示123

怎么将123这个值 无刷新的传到   http://www. 的文本框中 id为nr的文本框中

现在是要选择123  才能传过去

我想实现点提交后  自动把123传到文本框中

下面是aa.asp的代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www. >
<head>
<title>未命名頁面</title>
   
    <script type="text/javascript">
    <!--
    var xmlhttp;
   
    function createHTTP()
    {
        if (window.ActiveXObject)
        {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else if (window.XMLHttpRequest)
        {
            xmlhttp = new XMLHttpRequest();
        }
    }
   
    function GetData()
    {
        createHTTP();
        xmlhttp.onreadystatechange = StateChange;
        xmlhttp.open("GET", "http://www., false);
        xmlhttp.send();
    }
   
    function StateChange()
    {
        if (xmlhttp.readystate == 4)
        {
            if (xmlhttp.status == 200)
            {
                document.getElementById('frame1').contentWindow.document.body.innerHTML = xmlhttp.responseText;
                document.getElementById('frame1').contentWindow.document.onmouseup = ShowSelection;
            }
        }
    }
   
    function ShowSelection()
    {
        var selection = document.getElementById('frame1').contentWindow.document.selection;
        document.getElementById('txtShow').value = selection.createRange().text;
    }
   
    //-->
    </script>
   
</head>
<body onload="GetData()">
<p>
      <input type="text" id="txtShow" style="width:400px" />
</p>
<p>
  <iframe width="333" height="333" id="frame1" scrolling="No" frameborder="0" src="tjzp5.asp"></iframe>
</p>
</body>
</html>

[ 本帖最后由 guang2356447 于 2010-1-3 01:37 编辑 ]
4 回复
#2
icecool2010-01-03 12:24
    response.Write "<script>parent.text1.value='123'</script>"
#3
aspic2010-01-04 08:51
parent.document.getElementById("txtShow").value=
#4
guang23564472010-01-06 20:10
先谢谢2位

2楼说的   不太明白  不知道怎么用

3楼说的可以   但是要在 iframe那里面点一下  才能传到文本框中

有没有更好的办法   就是在iframe 定义一个session的值   有值的时候自动在文本框中显示 不用刷新
#5
aspic2010-01-07 08:31
tjzp5.asp页面提交后js改变父页面parent.document.getElementById("txtShow").value = document.getElementById("你的id").value
1