问题:
JSP+JAVASCRIPT : 父窗口中弹出子窗口,用户在子窗口选择,子窗口返回的用户选择。
1、父窗口 father.jsp中弹出子窗口son.jsp:父窗口变暗,不能操作;记住父窗口中用户未提交的选择(未提交保存)。
2、子窗口son.jsp中:用户选择若干项,关闭子窗口时,将用户选择传个父窗口。
方案:
父窗口中:
<script type="text/javascript">
function f1(){
var tcolor = document.bgColor;
var url= "跳转的ACTION"
//传递用户为保存的信息
……
document.bgColor="#CCCCCC";
var vReturn= window.showModalDialog(url,
null,
"dialogWidth:1000px;dialogHeight:800px;help:no;status:no");
document.bgColor = tcolor;
var action = "本ACTION"
//传递用户为保存的信息
……
document.form.action=action;
document.form.submit();
}
</script>
子窗口:
<script type="text/javascript">
function f2() {
var vInput = document.getElementsByName("控件名称");
var vRetrun= new Array(vInput .length);
for(var i=0;i<vInput .length;i++){
vRetrun[i] = new String(vInput[i].value);
}
window.returnValue=vRetrun;
window.close();
}
</script>
注意:
1、子窗口的对象不能直接返回。因为,返回的是引用;而在A 窗口不能访问B窗口的控件。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.