首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >确定用户是否在WebBrowser控件中选择了刷新

确定用户是否在WebBrowser控件中选择了刷新
EN

Stack Overflow用户
提问于 2012-11-28 01:55:40
回答 1查看 293关注 0票数 0

如何检测用户是否通过上下文菜单选择了Refresh?当用户选择NavigateComplete2方法时,它不会被调用。

更重要的是,要设置自己的自定义用户代理,一种方法是挂钩BeforeNavigate2事件方法,并且有必要知道用户是否选择了刷新或导航新的url。

任何洞察力都将不胜感激。

这说明在选择Refresh时不会触发NavigateComplete2方法。

代码语言:javascript
复制
oWB := new WebBrowserControl("http://stackoverflow.com")
Class WebBrowserControl
{

    __New(strURL) { 
        static WB
        Gui, New, Resize 
        Gui, Add, ActiveX, vWB w780 h580, Shell.Explorer  
        Gui, show, w800 h600

        ComObjConnect(WB, this) 

        WB.Navigate(strURL)
        Loop
           Sleep 10
        Until (WB.readyState=4 && WB.document.readyState="complete" && !WB.busy)    
        Return
        GuiClose:
        ExitApp
    }

    NavigateComplete2(oParams*) {
        ComObjError(false)  
        WB := oParams[1]
        msgbox, 64, Navigate Completed
            , % "WB.locationURL :`t`t" WB.locationURL "`n"
            . "WB.Document.URL:`t`t" WB.Document.URL "`n"
            . "windowlocation.href:`t" WB.document.parentWindow.location.href
    }

    BeforeNavigate2(oParams*) {

        WB := oParams[8]
        strURL := oParams[2]        

        msgbox % "Loading URL:`t`t" strURL "`n"
            . "WB.locationURL :`t`t" WB.locationURL "`n"
            . "WB.Document.URL:`t`t" WB.Document.URL "`n"
            . "location.href:`t`t" WB.document.parentWindow.location.href "`n"
            . "WB.ReadyState:`t`t" WB.readystate "`n"
            . "WB.document.readystate:`t" WB.document.readystate "`n"
            . "WB.Busy:`t`t`t" WB.Busy "`n"
    }
}
EN

回答 1

Stack Overflow用户

发布于 2012-12-01 20:26:05

查看是否已启动刷新(或新页面)的一种方法是使用if/while (A_Cursor = "AppStarting")监视鼠标状态(在Chrome中,不确定其他浏览器)。当鼠标光标变成沙漏时,这是正确的。

比较以前和新的网址,你会知道这是一个新的请求或刷新: ControlGetText CurrentURL,Chrome_OmniboxView1,Chrome

希望这能有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13590191

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档