有没有一种方法可以限制Web视图中的url数量 [英] Is there a way limit the no of urls in web view
问题描述
我正在用c#xaml编写Windows 8应用程序,正在使用Web视图,我想限制要在Web视图中加载的URL,因为有一些不必要的按钮,并且我们有特定的Web应用程序为了这个目的.那么我们可以限制可以在Web视图中加载的URL吗?
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?
我想到的一种方法是检查一个事件,一旦我们开始导航到新的URL,该事件将被触发.但是我无法在MSDN文档中找到一个.有什么想法吗?
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?
推荐答案
虽然不像发生导航事件那样简单,但是有一种解决方法可以利用ScriptNotify.
While not as simple as having a Navigating event, there is a workaround you can do leveraging ScriptNotify.
从根本上讲,这相当于遍历文档中的每个标记,并添加一个自定义Javascript调用,以使您知道发生了什么事情.但是,这并非万无一失,因为导航可能是通过Javascript触发的,而不是有人点击链接触发的.
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.
使用WebView时,您可能还会遇到其他一些问题.这是另一篇文章,介绍了它们以及一些解决方法.
There are a few other issues you can encounter when using the WebView. Here is another article covering them and some workarounds.
这篇关于有没有一种方法可以限制Web视图中的url数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!