单击视频的关闭按钮,应用程序关闭

我有一个wpf应用,视频中有一个关闭按钮。单击关闭按钮,整个应用程序将关闭。我要为cefsettings设置一些属性。

settings.CefCommandLineArgs.Add(“ disable-web-security”,“ 1”);
settings.CefCommandLineArgs.Add(“ allow-universal-access-from-files”,“ 1”);

如果我要设置这两个属性,则我的应用程序将关闭,否则不会关闭。

下面是单击关闭按钮时运行的javascript代码。

window.DoCPExit = function() {
    try {
        cp.em.fireEvent("cpmovieExit");
        if (cp.IsRunningInACAP || cp.IsRunningInALEC || cp.m_isLMSPreview) {
            cp.currentWindow.open("goodbye.html","_self");
            return
        }
        if (cp.IsRunningInRoboHelp) {
            var b = cp.currentWindow.open("","_self");
            b.close();
            return
        }
        if (cp.currentWindow != cp.parentWindow && cp.parentWindow && cp.parentWindow.hasOwnProperty("DoCPExit")) {
            if (cp.setallowForceQuitContainer) {
                cp.parentWindow.DoCPExit()
            } else {
                cp.currentWindow.close()
            }
        } else {
            if (cp.IsRunningInConnect()) {
                if (cp.setallowForceQuitContainer) {
                    cp.parentWindow.close()
                } else {
                    cp.currentWindow.close()
                }
            } else {
                if (cp.topWindow == self) {
                    (b = window.open("","_self"),b.close())
                } else {
                    if (cp.setallowForceQuitContainer) {
                        (b = cp.topWindow.open("",b.top.close())
                    } else {
                        (b = window.open("",b.close())
                    }
                }
            }
        }
    } catch (a) {}
    cp.pg && navigator && navigator.app && "function" === typeof navigator.app.exitApp && navigator.app.exitApp();
    cp.win8 && (window && window.parent) && window.parent.postMessage({
        name: "WIN8APPCLOSE",data: {}
    },"*");
    cp.currentWindow.open("goodbye.html","_self")
}
;

如果未设置以上两个属性,则将运行以下代码,并且应用程序可以按预期运行,即应用程序未关闭。

 if (cp.topWindow == self) {
    (b = window.open("",b.close())
 } 

如果设置了以上两个属性,则应用程序将关闭。上面的if条件变为false并将其放入下面的代码中,然后关闭应用程序。

 if (cp.setallowForceQuitContainer) {
    (b = cp.topWindow.open("",b.top.close())
 } 

我需要启用这两个属性,否则我将收到其他文件的跨域请求错误。

zengh225 回答:单击视频的关闭按钮,应用程序关闭

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3008536.html

大家都在问