question

AlanRojas-9586 avatar image
0 Votes"
AlanRojas-9586 asked JarvanZhang-MSFT edited

WebView events does not detect the url change

I want to navigate only to a youtube video and if I try to navigate to youtube home or another page inside youtube, i want to detect the url change and cancel it from loading. I have implemented the OnNavigating and OnNavigated event, a webview custom renderer to use ShouldOverrideUrl, PageStarted, PageFinished to detect the url change and nothing works. The only event that detect it is DoUpdateHistory but when it detect the url, the page is already loaded and i want to prevent loading another page.

It should be noted that when I try to navigate outside of YouTube, the events do work.

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered JarvanZhang-MSFT edited

Hello @AlanRojas-9586 ,​

Welcome to our Microsoft Q&A platform!

WebView events does not detect the url change

There are two ways to redirect web pages: Forward and Redirect. It exists a clear difference in the jump between the two ways.

Forward: The address bar of the browser URL remains unchanged.
Redirect: The address bar of the browser URL changes.

The youtube api seems to use the Forward way to redirect the url. When clicking a tab on the youtube home page, the related event will not be called. But these events are triggered when testing google web. You could test it on your side to vertify that.

Best Regards,

Jarvan Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AlanRojas-9586
May I know whether your issue has been solved or not? If not, please share it in here. We can work together to figure it out.

0 Votes 0 ·

I did not understand what you suggest me to do, sorry. I have not solve it yet.

0 Votes 0 ·

I mean the issue is not due to the WebView, it's related to the working mechanism of the youtube api.

The following case explains the difference between the two ways, please check:
https://stackoverflow.com/questions/6068891/difference-between-jsp-forward-and-redirect

0 Votes 0 ·