在jsp页面上出现“Handleonclose”功能

时间:2012-10-07 22:38:50

标签: javascript jsp

我有一个jsp文件调用另一个jsp文件,将其打开为showmodal对话框窗口。

假设file1.jsp通过file1.js调用file2.jsp。

File1.jsp - > File1.js(各自的js文件) File2.jsp - > File2.js(各自的js文件)

现在要在File2.jsp中处理闭包,我在File2.js中添加了一个函数。

当我点击关闭窗口但选择选项作为取消时,而不是仅显示旧窗口。 它在现有模态窗口的顶部显示模态窗口。为什么会这样呢?我错过了一些明显的东西。

我期望发生的事情:当我选择关闭但点击取消时,不会发生任何事情。

File2.js功能:

function handleOnClose() {

    var resultsDoc = document.frames('searchBuffer').document;

    if (event.clientY < 0) {
        var bool = confirm('Are you sure you want to close the window ?');
        if (!bool) { //Issue occurs here
            window.showModalDialog("File2.jsp", "", "dialogWidth:1000px;dialogHeight:650px");
        }
        else {
            resultsDoc.all('searchResults').innerText = '';

            document.someSearch.submit();
        }
    }

    window.returnValue = 'Discard';

}

1 个答案:

答案 0 :(得分:0)

修改了File2.js函数:

function handleOnClose() {

    var resultsDoc = document.frames('searchBuffer').document;

    if (event.clientY < 0) {
        var bool = confirm('Are you sure you want to close the window ?');
        if (!bool) { //Issue occurs here
            //*******removed the showmodal dialog window call
              window.returnValue = 'Sorry';
        }
        else {
            resultsDoc.all('searchResults').innerText = '';

            document.someSearch.submit();
    window.returnValue = 'Discard';
        }
    }

}

在调用js(file1.js)上,我检查返回值是否为“Discard”,如果是,我刷新页面。 否则我再次调用showmodal窗口。我的结果存储在缓冲区中,因此检索不是问题。像魅力一样工作