android webview shouldOverrideUrlLoading html iframe内部链接

来源:互联网 发布:仿站长之家网站源码 编辑:程序博客网 时间:2024/05/16 18:52

很多时候html中会嵌套iframe,这时候iframe里面的请求android通过shouldOverrideUrlLoading是无法拦截的,需要shouldInterceptRequest才可以拦截到。

但是shouldInterceptRequest会将所有请求拦截,比如.js\.css等等,这并不是我们想要的。

后来发现通过设置iframe内部页面的target可以实现将内部请求转发到shouldOverrideUrlLoading。具体如下:

在iframe内部的html的head中设置:<base target="_top">或<base target="_parent">即可。

0 0
原创粉丝点击