Having a C# WebBrowser control inside my WinForms application, and being aware of the Navigating event, I never came up with a nice and elegant solution to the following:
For case 1 there are some cases I can think of:
a tag and the href attribute is evaluated to load another URL.onclick javascript event handler which calls a function that uses window.location to load another URL.For case 2 I can imagine of:
iframe tag that loads an URL inside the IFrame. This fires the Navigating event.window.location to load another URL.meta refresh header tag to load another URL after some seconds.So my question is:
How to detect inside the Navigating event (or any other mechanism) whether a redirect is triggered explicitly by the user or implicitly by the page?
Some more information
WebBrowser is being used inside a windows based CMS backend application.(Please note that I do believe this is not a duplicate of this SO posting)
My take on this is capture user clicks on the web browser control. Have it set a flag that indicates that the user clicked on the web browser. If the flag is true, then allow redirection, if it isn't true don't allow it. Make sure to reset the flag after n number of seconds if no (or after) redirection is made.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With