Android9.0 Uncaught SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document

时间:2019-12-23 19:45:48   收藏:0   阅读:266
// 经过URL后就存在这个问题
mWebView.loadUrl(URL(originalUrl).toString())

最后 使用
loadDataWithBaseURL 方式
setItem使用拼接方式   再replace替换相应的地址才解决


val mimeType = "text/html"
val encoding = "utf-8"
val injection = "<script type=‘text/javascript‘>${paramJs}window.location.replace(‘$originalUrl‘);</script>"
KLog.i("-------> ${injection}")
// "<script type=‘text/javascript‘>localStorage.setItem(‘userInfo‘, ‘\"$tokenJson\"‘);window.location.replace(‘$originalUrl‘);</script>"
mWebView.loadDataWithBaseURL(originalUrl, injection, mimeType, encoding, null) //loadDataWithBaseURL

原文:https://www.cnblogs.com/caosq/p/12087849.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!