当不可见时如何在Twebbrowser控件中强制加载页面 [英] How to force load a page in Twebbrowser control when this is not visible

查看:61
本文介绍了当不可见时如何在Twebbrowser控件中强制加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从delphi代码执行一些javascript函数,但是如果未将页面加载到Twebbrowser控件中,则此函数将失败.因此,问题在于,如果页面不在Tabshet中,则该页面处于非活动状态,直到该Tabsheet处于活动状态,页面才会加载.

i need to execute some javascript functions from delphi code, but this functions fails if the page is not loaded in the Twebbrowser control. so the problem is if page is located in a tabshet wich is not active the page is not loaded until the tabsheet is become active.

问题是当不可见时如何在 Twebbrowser 控件中强制加载页面.

the question is How to force load a page in a Twebbrowser control when this is not visible.

要测试此行为,只需在第二个选项卡中放置一个带有2个选项卡的pagecontrol和一个twebbrowser,现在在表单的oncreate事件中放置此代码

to test this behaviour just put a pagecontrol, with 2 tabsheets , and a twebbrowser in the second tabsheet, now in the oncreate event of the form put this code

WebBrowser1.Navigate('http://stackoverflow.com');

现在,当您运行应用程序时,只有在使第二个选项卡可见时,页面才会加载.

now when you run the app the page only loads when you makes the second tabsheet visible.

提前谢谢.

推荐答案

调用 WebBrowser1.HandleNeeded; ,然后再调用 WebBrowser1.Navigate

这篇关于当不可见时如何在Twebbrowser控件中强制加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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