Is there a way limit the no of urls in web view

时间秒杀一切 提交于 2020-01-17 05:20:11

问题


I am writing a windows 8 application in c# xaml , I am using using a web view, I want to limit the URLs to be loaded in the web view as there are some buttons which are not necessary and we have specific web apps for that purpose. So can we limit the URLs that can be loaded in a web view?

A way I thought of was to check for an event which will be fired once we start navigating to a new URL. But I could not get one in MSDN doc. Any thoughts?


回答1:


While not as simple as having a Navigating event, there is a workaround you can do leveraging ScriptNotify.

How to emulate navigating event in the WebView

It basically amounts to iterating over every a tag in the document, and adding a custom Javascript call letting you know that something is happening. This isn't fool proof however, as it's possible the navigation is triggered via Javascript and not someone clicking on a link.

There are a few other issues you can encounter when using the WebView. Here is another article covering them and some workarounds.

Metro WebView Source Workarounds



来源:https://stackoverflow.com/questions/14325007/is-there-a-way-limit-the-no-of-urls-in-web-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!