检测浏览器是否支持谷歌图表
昨天,我在运行 Opera 时遇到了网站上一些谷歌图表的问题。我收到错误“您的浏览器不支持图表”。今天一切都很好,而且事实上似乎运行得更快了一些。
我想在我的 javascript 中有一个备份,这样如果不支持它,我只会显示一个表格。
有没有这样的方法可以做到这一点,或者我是否需要检查传入浏览器的列表并自己找出答案?
Yesterday I was having an issue with some google graphs on my site while running opera. I was getting the error "your browser does not support graphs". Today Its absolutely fine and in fact seems to be running a bit quicker.
I'd like to have a backup in my javascript so that if its not supported Ill just display a table.
Is there any such way to do this or do i need to check against a list of incoming browsers and figure it out for myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 http://code.google.com/intl/en/ apis/chart/interactive/docs/:
他们显然正在使用内联 SVG。 http://caniuse.com/#search=inline%20svg 不是很有用这里因为这是关于 HTML5 解析器识别 SVG 内容,但是 Google 正在动态生成 SVG 内容。我认为以下代码片段可以正确测试内联 SVG 支持:
如果动态创建的 SVG 元素具有 SVG 特定的属性,那么一切都应该没问题。您仍然必须假设 MSIE 得到普遍支持(通过 VML)。或者使用如何做您在浏览器中检测对 VML 或 SVG 的支持以检测 VML 支持。这有望与谷歌正在执行的兼容性检查相匹配(减去您明显观察到的故障)。
From http://code.google.com/intl/en/apis/chart/interactive/docs/:
They are apparently using inline SVG. http://caniuse.com/#search=inline%20svg isn't very useful here because that's about HTML5 parser recognizing SVG content, Google is generating SVG content dynamically however. I think that the following code snippet tests for inline SVG support correctly:
If a dynamically created SVG element has SVG-specific properties then everything should be fine. You will still have to assume that MSIE is generally supported (via VML). Or use How do you detect support for VML or SVG in a browser to detect VML support. And that will hopefully match the compatibility checks that Google is performing (minus glitches like the one you apparently observed).