嵌入式IE浏览器:导航完成前如何检测重定向? [英] Embedded IE browser: how to detect redirect before navigation completes?
问题描述
我正在嵌入式浏览器中托管OAuth页面。我想尽快关闭登录页面而不等待加载重定向页面(OAUth提供者需要有效的重定向URL)。
I am hosting an OAuth page in an embedded browser. I want to close the login page as soon as possible without waiting for the redirect page to load (the OAUth provider requires a valid redirect url).
如何检测导航重定向网址? OnBeforeNavigate触发一个url,但OnNavigateComplete触发最终url,它(显然)需要时间来导航和加载页面。我宁愿在浏览器实际访问最终重定向页面之前通过检测重定向和挽救来跳过该步骤。
How do I detect navigation to the redirect url? OnBeforeNavigate fires for one url, but OnNavigateComplete for the final url, and it (obviously) takes time to navigate and load the page. I would prefer to skip that step by detecting redirect and bailing out before the browser actually hits the final redirect page.
谢谢!
推荐答案
在IDocHostUIHandler的主机实现中:: GetHostInfo,打开DOCHOSTUIFLAG_ENABLE_REDIRECT_NOTIFICATION标志。然后,您将为每个重定向获取DWebBrowserEvents2 :: BeforeNavigate2,并且可以根据需要取消重定向。
In the host implementation of IDocHostUIHandler::GetHostInfo, turn on the DOCHOSTUIFLAG_ENABLE_REDIRECT_NOTIFICATION flag. You will then get a DWebBrowserEvents2::BeforeNavigate2 for each redirect, and can cancel a redirect if you want.
这篇关于嵌入式IE浏览器:导航完成前如何检测重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!