如下情况,我该如何去实现效果?有什么好办法?

情况是这样的,先有一个页面,点击按钮弹出对话框,里面有链接,点击链接过去会切换到另一个列表页,在这边获取数据确定之后关闭窗口,然后再最开始的页面中获取数据并显示在一个对话框中,要如何实现呢。
之前做过一个对话框中不切换页面的,只需在对话框中用window.parent.setValue(数据)就可以传回去了,但是切换页面后提示window.parent不支持setValue()对象。
也试过window.showModalDialog()来打开对话框,然后通过window.returnValue()来返回参数。依然提示不支持returnValue()函数。
注:setvalue是我自己写的函数。

森林海
浏览 143回答 2
2回答

慕娘9325324

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">&nbsp;<HTML>&nbsp;<HEAD>&nbsp;<TITLE>New Document </TITLE>&nbsp;<META content="EditPlus" name="Generator">&nbsp;<META content="" name="Author">&nbsp;<META content="" name="Keywords">&nbsp;<META content="" name="Description">&nbsp;<script language="javascript">&nbsp;<!--&nbsp;function openChild(){&nbsp;var aa = document.getElementById("txt9").value;&nbsp;var k = window.showModalDialog("child.html",aa,"dialogWidth:335px;status:no;dialogHeight:300px");&nbsp;if(k != null)&nbsp;document.getElementById("txt11").value = k;&nbsp;}&nbsp;//-->&nbsp;</script>&nbsp;</HEAD>&nbsp;<BODY>&nbsp;<FONT face="宋体"></FONT>&nbsp;<br>&nbsp;传递到父窗口的值:<input id="txt9" type="text" value="33333" name="txt9"><br>&nbsp;返回的值:<input id="txt11" type="text" name="txt11"><br>&nbsp;子窗口设置的值:<input id="txt10" type="text" name="txt10"><br>&nbsp;<input id="Button1" onclick="openChild()" type="button" value="openChild" name="Button1">&nbsp;</BODY>&nbsp;</HTML>&nbsp;child.html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">&nbsp;<HTML>&nbsp;<HEAD>&nbsp;<TITLE>New Document </TITLE>&nbsp;<META content="EditPlus" name="Generator">&nbsp;<META content="" name="Author">&nbsp;<META content="" name="Keywords">&nbsp;<META content="" name="Description">&nbsp;<meta http-equiv="Expires" content="0">&nbsp;<meta http-equiv="Cache-Control" content="no-cache">&nbsp;<meta http-equiv="Pragma" content="no-cache">&nbsp;</HEAD>&nbsp;<BODY>&nbsp;<FONT face="宋体"></FONT>&nbsp;<br>&nbsp;父窗口传递来的值:<input id="txt0" type="text" name="txt0"><br>&nbsp;输入要设置父窗口的值:<input id="txt1" type="text" name="txt1"><input id="Button1" onclick="setFather()" type="button" value="设置父窗口的值" name="Button1"><br>&nbsp;输入返回的值:<input id="txt2" type="text" name="txt2"><input id="Button2" onclick="retrunValue()" type="button" value="关闭切返回值" name="Button2">&nbsp;<input id="Button3" onclick="" type="button" value="关闭刷新父窗口" name="Button3">&nbsp;<script language="javascript">&nbsp;<!--&nbsp;var k=window.dialogArguments;&nbsp;//获得父窗口传递来的值&nbsp;if(k!=null)&nbsp;{&nbsp;document.getElementById("txt0").value = k.document.getElementById("txt9").value;&nbsp;}&nbsp;//设置父窗口的值&nbsp;function setFather()&nbsp;{&nbsp;k.document.getElementById("txt10").value = document.getElementById("txt1").value&nbsp;}&nbsp;//设置返回到父窗口的值&nbsp;function retrunValue()&nbsp;{&nbsp;var s = document.getElementById("txt2").value;&nbsp;alert(s);window.returnValue=s;&nbsp;window.close();&nbsp;}&nbsp;//-->&nbsp;</script>&nbsp;</BODY>&nbsp;</HTML>

慕尼黑的夜晚无繁华

直接使用js的函数简单介绍一下JavaScript alert()函数的使用,alert--弹出消息对话框,并且alert消息对话框通常用于一些对用户的提示信息。  JavaScript alert()函数  alert--弹出消息对话框(对话框中有一个OK按钮)  alert,中文"提醒"的意思  alert函数语法  alert(str);  alert函数提示框图示    alert函数参数  str--要显示在消息对话框中的文本  alert函数说明  alert消息对话框通常用于一些对用户的提示信息,例如在表单中输入了错误的数据时。  提示:消息对话框是由系统提供的,因此样式字体在不同浏览器中可能不同。  提示:消息对话框是排它的,也就是在用户点击对话框的按钮前,不能进行任何其它操作。  提示:消息对话框通常可以用于调试程序。  示例alert("Hellodreamdu!"); alert('Welcometo<br/>dreamdu!'); alert('Welcometo\ndreamdu!');&nbsp;&nbsp;  注意上面的第二个与第三个例子,只有第三个例子才能实现换行,参考ASCII码表,使用HTML中的br标签无法换行。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript