在事件发生之前,webbrowser不会显示页面 [英] webbrowser does not display page until an event occurs

查看:47
本文介绍了在事件发生之前,webbrowser不会显示页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows CE设备上使用.net紧凑框架webbrowser控件..Net应用程序具有在不同线程下的设备上运行的Web服务器.Web浏览器按照正常的浏览器功能与Web服务器进行交互.问题在于,当请求页面时,直到出现某些浏览器事件时,屏幕才会始终显示.

I am using the .net compact framework webbrowser control on a Windows CE device. The .Net application has a web server running on the device under a different thread. The webbrowser interacts with the web server as per normal browser functionality. The problem is that when pages are requested the screen does not always display until there is some browser event.

一个例子是,如果我在页面的脚本中放入了Javascript alert(...)语句.屏幕将空白,并显示消息,当您单击确定时,将显示整页

An example is if I put a Javascript alert(...) statement within the page's script. The screen will blank and the message will display and when you click the ok the full page displays

另一个示例是用户导航时页面空白.单击屏幕上的任意位置,将显示该页面.

Another example is the page goes blank when the user navigates. Click anywhere on the screen and the page will display.

似乎正在加载页面,但web浏览器控件已锁定,并且在发生用户事件之前不会显示任何内容.

It seems as if the pages are loading but the webbrowser control is locked and will not display anything until there is a user event.

DocumentCompleted()事件确实触发了,在我尝试过的那个事件中

DocumentCompleted() event does fire, within that event I have tried

        webBrowser.Invalidate();
        webBrowser.Update();
        webBrowser.Refresh();

但是,直到用户用手写笔点击屏幕后,页面才会显示.

But the page will not display until the user taps the screen with the stylus.

推荐答案

使用WebBrowser控件的DocumentCompleted事件,如下所示:

Use the DocumentCompleted event of the WebBrowser control, like this:

private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    // hack for Windows CE based devices in order to get the page load right
    webBrowser.Width--;
    webBrowser.Width++;
}

这篇关于在事件发生之前,webbrowser不会显示页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆