根据 cordova iOS WebView Guide你可以在 iOS 中嵌入 WebView 。
据此你可以做
<content src="http://apache.org" />
定义
CDVViewController* viewController = [CDVViewController new];
我想知道是否有办法检测该内容源是否通过单击链接导航到另一个站点,以及是否有办法获取新 URL?
CDVViewController是被引用的那个,但我无法通过检查来判断如何实现它。
与此略有相似的是微软的 x-ms-webview
在 DOM 级别允许我这样做:-
var webView = document.getElementByTag("x-ms-webview"); webView.addEventListener("MSWebViewNavigationCompleted", function (arg) { if (arg.uri.match(/something)) { doSomething(); } });
另一个example in iOS but just for loading initial page .
如何在 Cordova iOS 中检测 WebView 内的导航?
最佳答案
Cordova 在页面加载时发布 CDVPageDidLoadNotification
。
你可以听
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageDidLoad:) name:CDVPageDidLoadNotification object:self.webView];
关于javascript - 如何检测 cordova iOS WebView 导航事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48776906/