简体   繁体   English

如何关闭Xpage中的窗口?

[英]How do I close my window in Xpage?

Actually I am using the following code for closing my current window: 实际上我使用以下代码关闭当前窗口:

window.close()

The thing is, it is working fine in IE, but it is not working in FF and Chrome. 问题是,它在IE中运行良好,但它不适用于FF和Chrome。

Is their any great solution for doing this? 这是他们做这个的好方法吗?

I found a partial solution, Java is your friend. 我找到了部分解决方案,Java是你的朋友。 It works in a button should work in a link too. 它在按钮中工作也应该在链接中工作。 The only problem is when called from an event like onClose the current xpage looses focus and the current pages stays open. 唯一的问题是当从onClose这样的事件调用时,当前的xpage失去焦点并且当前页面保持打开状态。 I tried to emulate send keys and it presses the ESC key. 我试图模拟发送键,然后按ESC键。 It works fine from a button in. Button on CLick event 它可以在CLick事件中的按钮中正常工作

<xp:button value="Label" id="button1">
    <xp:eventHandler event="onclick" submit="true"
        refreshMode="complete">
        <xp:this.action><![CDATA[#{javascript:var robot:java.awt.Robot= new java.awt.Robot;var event:java.awt.event.KeyEvent=java.awt.event.KeyEvent;

robot.keyPress(event.VK_ESCAPE); robot.keyPress(event.VK_ESCAPE); robot.keyRelease(event.VK_ESCAPE); robot.keyRelease(event.VK_ESCAPE); enter code here }]]> enter code here }]]>

    </xp:eventHandler>
</xp:button>
function windowclose(w) {
    try {
        if (dojo.isIE>=7) {
            w.open('', '_self', '');
            w.close();
        } else if (dojo.isIE==6) {
            w.opener = null;
            w.close();
        } else {
            if(!w.opener)
                w.opener = 'x';
            w.close(); 
        }
    } catch(e) {
        alert("To avoid data corruption/loss, please close this window immediately.");
    }
}

To be used as: 用作:

windowclose(window)

window.close() works in 8.5.3 but only if parent contains an object and it will not do this if you have ie an xpage that is opened inside an ordinary Notes application or a ordinary view. window.close()在8.5.3中工作,但只有当父包含一个对象时,如果你有一个在普通的Notes应用程序或普通视图中打开的xpage,它就不会这样做。 you need a window.open to get this. 你需要一个window.open来获得这个。

I have investigated alot about this a while ago but no luck finding an answer. 我刚刚调查了很多这个,但没有找到答案的运气。 The only way I found is that you need the Mindoo XPage2Esclipse plugin to get this to work. 我发现的唯一方法是你需要Mindoo XPage2Esclipse插件来实现这一点。

您可能必须在Firefox中调用window.close()之前调用window.focus()

I use window.close with no problems in 8.5.3 apps with Chrome / FF / IE. 我在使用Chrome / FF / IE的8.5.3应用程序中使用window.close没有问题。

In the main page of an app, the "Case Document" I have some CSJS at the top that names the page ie. 在应用程序的主页面中,“案例文档”我在顶部有一些CSJS,用于命名页面即。

window.name="mainWindow";

and then I have a button that allows you to ask a question - this pops up a new window/tab and keeps the main case doc open as well. 然后我有一个按钮,允许你提出一个问题 - 这会弹出一个新的窗口/选项卡,同时保持主案例文档打开。 In the new window, there's a submit button that does a full update and in the onComplete event I have the following CSJS to update the main doc so you can see the question on the main doc in the repeat control that shows the threads of Q & A docs: 在新窗口中,有一个完整更新的提交按钮,在onComplete事件中我有以下CSJS来更新主文档,这样你就可以在重复控件中的主文档上看到问题,显示Q&的线程文档:

    if (window.opener!=null){
        window.opener.location.href = window.opener.location.href; 
        window.close();}
    else {
        alert("Can't refresh parent case doc - have you closed the window?");
    }

Hope this helps 希望这可以帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从PeopleCode关闭窗口? - How do I close a window from PeopleCode? 如何在 JavaScript/jQuery 中关闭窗口? - How do I close a window in JavaScript/jQuery? 当我切换菜单以关闭窗口并调整窗口大小时,如何防止徽标消失? - How do I prevent my logos from disappearing when I toggle my menu to close and resize my window? 验证某些$ _POST变量是否正确后,我希望窗口关闭。 我该如何使用JQuery? - After I've validated if some $_POST variables are correct, I want my window to close. How do I do this with JQuery? 使用Java加载后打开的窗口如何关闭? - How do I close a window I opened after it loads with Javascript? 如何在未收到“是否要关闭此窗口”提示的情况下关闭浏览器窗口? - How can I close a browser window without receiving the “Do you want to close this window” prompt? 打开和关闭面板时,如何防止浏览器窗口跳回到页面顶部? - How do I prevent the browser window from jumping back to the top of the page when when I open and close my panel? 如何在电子js中创建新窗口,以使原始窗口在关闭新窗口之前不可用? - How do I create a new Window in electron js such that the original window is unusable until i close the new window? 在Javascript(不是JQuery)中,如何使窗口在2秒后关闭? - In Javascript (not JQuery), how do I make the window close after 2 seconds? 如何在 AJAX 成功后关闭模式 window - How do I close a modal window after AJAX success
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM