jxbrowser语言 - - jquery.你确定吗 .警告消息始终为英文..



我试图使用jquery。AreYouSure into JxBrowser(5.2 和/或下一版本)。jquery.你确定工作...但是警告弹出窗口总是英文的...这种行为是错误的,与chrome/firox/ie不同。这些显示当前语言的消息...

这是一个演示网址

http://www.papercut.com/products/free-software/are-you-sure/demo/are-you-sure-demo.html

默认情况下,JxBrowser 显示使用英语配置的对话框。同时,JxBrowser API 提供了允许修改默认行为并使用所需语言显示您自己的对话框的功能。要更改语言,您需要注册自己的DialogHandler您可以在其中显示自己的对话框。例如:

import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.CloseStatus;
import com.teamdev.jxbrowser.chromium.UnloadDialogParams;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import com.teamdev.jxbrowser.chromium.swing.DefaultDialogHandler;
import javax.swing.*;
import java.awt.*;
/**
 * The sample demonstrates how to catch onbeforeunload dialog.
 */
public class BeforeUnloadSample {
    public static void main(String[] args) {
        Browser browser = new Browser();
        final BrowserView view = new BrowserView(browser);
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setVisible(true);
        browser.setDialogHandler(new DefaultDialogHandler(view) {
            @Override
            public CloseStatus onBeforeUnload(UnloadDialogParams params) {
                String title = "Confirm Navigation";
                String message = params.getMessage();
                int returnValue = JOptionPane.showConfirmDialog(view, message, title, JOptionPane.OK_CANCEL_OPTION);
                if (returnValue == JOptionPane.OK_OPTION) {
                    return CloseStatus.OK;
                } else {
                    return CloseStatus.CANCEL;
                }
            }
        });
        browser.loadHTML("<html><body onbeforeunload='return myFunction()'>" +
                "<a href='http://www.google.com'>Click here to leave</a>" +
                "<script>function myFunction() { return 'Leave this web page?'; }" +
                "</script></body></html>");
    }
}

最新更新