<!--父窗口JS-->
//查看審核詳細
function viewFlow() {
var strBackValue= openWin('../VertifyView.aspx?&rn=' + Math.random()+'&View='+strValue, 630, 180);//這里的strBackValue就是模態窗口的返回值
alert(strBackValue)
}
//彈窗
function openWin(url, width, height) {
return window.showModalDialog(url, null, 'dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;');
}
<!--模態窗口JS-->
function save() {
var arr = ['A', 'B', 'C', 'D', 'E', 'F'];
var strValue = '';
$(':checkbox:checked').each(function(i) {
if($(':checkbox').parent().hasClass('radio')) {
strValue = strValue + ($(this).next().text() + "\n");
} else {
strValue = strValue + (arr[i] + "、" + $(this).next().text() + "\n");
}
});
window.returnValue = strValue;將需要傳遞到父窗口的值保存在window.returnValue中
window.close(); //關閉窗口
}
注:returnValue除了可以是布爾值,整型值等以外還可以是個js數組,用來傳遞大量數據。
待優化的問題:如果在彈窗的模態窗口未關閉之前,就對父窗口進行操作應該使用什么方式(如點擊模態窗口的的數據,給父窗口某一個控件賦值???)