0

假设我有一个 Mac OS X 应用程序,它链接到 WebKit 并使用 WebView 来显示 Web 内容。

如果此 webview 中的 JavaScript 调用该window.history.pushState()方法,我如何在 Objective-C 中检测到这一点?

理想情况下,我正在寻找类似于 ObjC 委托回调的东西,它会通知我的应用程序:“pushState() 是使用这些参数调用的:XXX”。


注意:我真的在寻找 ObjC 中的解决方案。假设我不能接受页面上的 JS 并替换/调整pushState()JS 中的方法。

4

1 回答 1

2

我在 WebKit 源代码树中找到了这些私有 API。这正是我正在寻找的,除了它们是私有的,这可能会给我的特定用例带来问题。

@interface NSObject (WebFrameLoadDelegatePrivate)
...
- (void)webView:(WebView *)wv didPushStateWithinPageForFrame:(WebFrame *)frame ;
- (void)webView:(WebView *)wv didReplaceStateWithinPageForFrame:(WebFrame *)frame;
- (void)webView:(WebView *)wv didPopStateWithinPageForFrame:(WebFrame *)frame;
@end
于 2012-07-23T21:16:03.073 回答