在 WebView 中禁用 HTML5,而不禁用 Javascript
出于诊断目的,我需要能够在 Android 的 WebView 中禁用 HTML5,无需禁用 Javascript(即保留 WebSettings.setJavaScriptEnabled(true);
)
进一步澄清:我喜欢无需安装任何 Flash 插件即可播放 YouTube 视频的能力。它甚至可以与 setPluginsEnabled(false)
配合使用。感谢 WebView 的 HTML5 内置支持,我可以做到这一点。现在,为了测试某个功能,我需要在不禁用 Javascript 的情况下使用 YouTube 视频触发 DownloadListener.onDownloadStart()
。
这可能吗?
更新:自从我发布这个问题以来,我发现至少 可以禁用 DOM 存储。我还没有找到禁用 HTML5 视频的方法。
For diagnostic purposes, I need to be able to disable HTML5 in Android's WebView, without disabling Javascript (i.e. keep WebSettings.setJavaScriptEnabled(true);
)
To further clarify: I love the ability to play YouTube videos without any Flash plugin installed. It even works with setPluginsEnabled(false)
. I can do this thanks to WebView's HTML5 built-in support. Now, to test a certain function, I need to trigger DownloadListener.onDownloadStart()
with a YouTube video without disabling Javascript.
Is this possible?
Update: Since I posted this question I discovered that at least DOM storage can be disabled. I haven't found a way to disable HTML5 video yet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这是一个非常古老的问题......不过,您可能想检查这个答案以获取想法。
WebSettings
类具有以下用于启用/禁用 HTML5 功能的方法:I know it's very old question... Still, you may want to check this answer for an idea. The
WebSettings
class has these methods for enabling/disabling HTML5 features:我不确定这个问题是否有意义。您无法在支持 HTML5 的浏览器中“禁用”该功能。您可能做的最好的事情就是在网页上设置非 HTML5 文档类型,但即使如此,大多数渲染引擎(包括 webkit)仍然会很乐意支持这些功能(
标记、
等)他们实现的。
听起来您真正想做的是测试特定设备上的流媒体视频会发生什么(使用较旧的?..版本的 webkit 不支持
) 。是这样吗?在这种情况下,我不知道与 Android 一起分发的 任何 版本的 Webkit 不支持
,但我可以错误的。
I am not sure that this question makes much sense. You're not going to be able to "disable" an HTML5 feature in a browser that supports it. The best you can probably do is to set a non-HTML5 doctype on the webpage, but even then most rendering engines (webkit included) will still gladly support those features (
<video>
tag,<canvas>
, etc) that they implement.It sounds like what you're really trying to do is test what happens with a streaming video on a particular device (with an older?.. version of webkit that doesn't support
<video>
). Is that right? In this case, I'm not aware of any version of Webkit that has ever been distributed with Android that does not have support for<video>
, but I could be wrong.