首页 > 解决方案 > 在 CefSharp 中允许外部应用程序

问题描述

我对 CefSharp 有疑问。我希望浏览器在时间到时自动打开一个外部应用程序。但它不起作用。

在最后一个之后click eventButton它总是显示一个空白页。

我试过这个: How to open a link in a native browser from CefSharp 3 但它不起作用。

public partial class CefTest : Form
{
    public CefTest()
    {
        InitializeComponent();
    }
    public ChromiumWebBrowser browser;
    private void CefTest_Load(object sender, EventArgs e)
    {
        CefInitialize();
        browser.FrameLoadEnd += Browser_FrameLoadEnd;
    }
    private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
    {
        browser.ExecuteScriptAsync("document.getElementById('tckn').value='...'");
        browser.ExecuteScriptAsync("document.getElementById('password').value='...'");
        browser.ExecuteScriptAsync("document.getElementsByClassName('nl-form-send-btn')[0].click()");
        browser.ExecuteScriptAsync("if (document.getElementById('joinMeeting') != null) document.getElementById('joinMeeting').click()");
        browser.ExecuteScriptAsync("document.getElementById('join').click()"); //When this clicked, it must open external app. But it shows blank page.
        
    }

    public void CefInitialize()
    {
        CefSettings settings = new CefSettings();
        Cef.Initialize(settings);

        browser = new ChromiumWebBrowser("https://giris.eba.gov.tr/EBA_GIRIS/giris.jsp");
        browser.Dock = DockStyle.Fill;
        panel1.Controls.Add(browser);
    }
}

<!--This is first box.-->
<div class="card shadow mb-5 rounded">
    <h4 class="info-text mb-3 mt-1" id="live-title">Human in Nature</h4>
    <h4 class="info-text mb-3">
        <span id="course-name">English</span>
    </h4>
    <h4 class="mb-4"><i class="far fa-clock"></i> <span id="live-times">15.50    - 16.20</span></h4>
    <a id="joinMeeting" href="" class="btn btn-warning disabled mb-2">Join Now</a>
</div>

<!--This opens when clicked button (joinMeeting)-->
<div class="modal-content">
    <a id="cancel" class="btn btn-secondary" data-dismiss="modal">Cancel</a>
    <a id="join" class="btn btn-success" data-dismiss="modal"><i class="fas fa-video"></i>Join</a>
</div>

<!--This is opens when clicked button (join) and starts lesson timer.-->
<div class="modal-content">
    <div class="modal-header">
        <h5 class="modal-title" id="remainingTimeModalLabel">Countdown</h5>
        <div style="text-align:center;">Time Left: <b><span     id="remaining_time_popup_text">4</span>sn</b></div>
    </div>
</div>

<!--When the timer finishes counting, "EBA Live Course.exe" starts     automatically.-->

标签: c#jquerychromiumcefsharpmouseclick-event

解决方案


推荐阅读