首页 > 解决方案 > 在 Webview 中运行 html 标签脚本

问题描述

我有一项服务,它返回一个 html 代码以在我的应用程序的 web 视图上呈现,有时它返回一个 youtube 嵌入、istagram 或 facebook,但 facebook 是唯一一个不工作的服务。

"<script async=\"1\" defer=\"1\" crossorigin=\"anonymous\" src=\"https://connect.facebook.net/pt_BR/sdk.js#xfbml=1&version=v8.0\" nonce=\"dUFa7MFK\"></script><div class=\"fb-video\" data-href=\"https://www.facebook.com/terradememe/videos/222040112417866\"><blockquote cite=\"https://www.facebook.com/terradememe/videos/222040112417866/\" class=\"fb-xfbml-parse-ignore\"><a href=\"https://www.facebook.com/terradememe/videos/222040112417866/\">Algumas histórias assustadoras!</a><p>Algumas histórias assustadoras!\n"

这只是身体的一部分,在 facebook 视频上,我们将其放在script标签上,当我播放视频时,应用程序冻结并且什么也不做,但如果我按下后退按钮,应用程序会将其恢复为正常行为。

我看到了一个使用 a 的解决方案,iframe但就我而言,我需要使用script.

过了一会儿,我注意到了这个日志:

"Refused to load the image 'android-webview-video-poster:default_video_poster/-1751309467915793562' because it violates the following Content Security Policy directive: "default-src * data: blob: 'self'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback."

有人遇到过同样的问题吗?

标签: androidhtmlfacebookwebview

解决方案


推荐阅读