检测对 VML 的支持,帮助应用之前的帖子

发布于 2024-08-18 13:07:35 字数 691 浏览 9 评论 0原文

我在上一篇文章中找到了以下内容,但需要一些帮助:

// For VML detection, here's what google maps does (search for "function Xd"):

function supportsVml() { 
  if (typeof supportsVml.supported == "undefined") { 
    var a = document.body.appendChild(document.createElement('div')); 
    a.innerHTML = '<v:shape id="vml_flag1" adj="1" />'; 
    var b = a.firstChild; 
    b.style.behavior = "url(#default#VML)"; 
    supportsVml.supported = b ? typeof b.adj == "object": true; 
    a.parentNode.removeChild(a); 
  } 
  return supportsVml.supported;
} 

当不支持 VML 时,我想使用代码将用户转移到另一个页面。请有人告诉我如何编写和实现代码以转移到名为 Alternative.html 的页面。

我对javascript有一些了解,但还不到这个水平!

谢谢。

I found the following in a previous post but need some help with it:

// For VML detection, here's what google maps does (search for "function Xd"):

function supportsVml() { 
  if (typeof supportsVml.supported == "undefined") { 
    var a = document.body.appendChild(document.createElement('div')); 
    a.innerHTML = '<v:shape id="vml_flag1" adj="1" />'; 
    var b = a.firstChild; 
    b.style.behavior = "url(#default#VML)"; 
    supportsVml.supported = b ? typeof b.adj == "object": true; 
    a.parentNode.removeChild(a); 
  } 
  return supportsVml.supported;
} 

I would like to use the code to divert users to an alternative page when VML is not supported. Please could somebody show me how to write and implement the code to divert, say, to a page called alternative.html.

I have some knowledge of javascript but not this level!

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一绘本一梦想 2024-08-25 13:07:35

您只需调用 Google 提供的该函数即可,如果支持 VML,它将返回 true,否则返回 false。不要忘记,您仍然需要在 HTML 中的某处添加 VML 的 xmlns。

if (!supportsVml())
    window.location = "http://somedomain.com/no-vml.html";

另外,我建议使用跨浏览器库来绘制矢量图形。这篇博文中有一些可供选择: Canvas/SVG/VML 绘图综述

You can just make a call to that function provided by Google, and it will return true if VML is supported and false if not. Don't forget, you will still need to add the xmlns for VML somewhere in your HTML.

if (!supportsVml())
    window.location = "http://somedomain.com/no-vml.html";

Also, I would recommend using a cross-browser library for drawing vector graphics. There's a few to choose from in this blog post: Canvas/SVG/VML Drawing Roundup.

回首观望 2024-08-25 13:07:35

仅 Internet Explorer(自 5.0 起)支持 VML,任何其他浏览器均不支持。所以检查 IE 应该就足够了。这可以通过多种方式完成,例如:!!document.namespaces

VML is only supported in Internet Explorer (as of 5.0) and is not supported in any other browser. So checking for IE should be just enough. This can be done in many ways, for example: !!document.namespaces

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文