如何使用Javascript检测SVG动画并显示/隐藏Flash/SVG对象?

如何使用Javascript检测SVG动画并显示/隐藏Flash/SVG对象?,javascript,firefox,animation,svg,browser-feature-detection,Javascript,Firefox,Animation,Svg,Browser Feature Detection,我一直在尝试使用SMIL创建SVG动画。它在最新的Firefox中运行良好,但当然在IE中不起作用。我已经有了类似的Flash动画。我的计划是在页面上包含Flash和SVG动画,并基于javascript检测显示/隐藏它们。但是我对javascript很糟糕,不知道怎么做。我将使用一个链接的.js文件。我的计划是检测浏览器是否支持该功能“http://www.w3.org/TR/SVG11/feature#AnimationEventsAttribute加载页面时,如果支持,则隐藏Flash对象

我一直在尝试使用SMIL创建SVG动画。它在最新的Firefox中运行良好,但当然在IE中不起作用。我已经有了类似的Flash动画。我的计划是在页面上包含Flash和SVG动画,并基于javascript检测显示/隐藏它们。但是我对javascript很糟糕,不知道怎么做。我将使用一个链接的.js文件。我的计划是检测浏览器是否支持该功能“http://www.w3.org/TR/SVG11/feature#AnimationEventsAttribute加载页面时,如果支持,则隐藏Flash对象(id=“rotateFlash”)并显示SVG对象(id=“rotateSVG”)

我不知道是否有更好的方法来实现我想要的,而且我还没有在网上找到任何类似于我试图实现的代码。我发现了show/hide javascripts,但不知道如何用它们实现检测功能

这段代码似乎至少做了些什么,但它似乎遵循了“else”命令,我猜这意味着Firefox没有检测到该功能为“True”(IE9也没有,但这是意料之中的)


我不知道还能做什么。我尝试过其他更简单的SVG特性,但得到了相同的结果。我一直在读有关现代化的书,但对我来说似乎太复杂了。我不明白如何,为什么,如果它能工作。

我想我终于让它工作了。查看代码后,我觉得
==“true”
没有必要,所以我删除了它。现在它似乎可以在Firefox13和IE9中使用

function supportsSvg() {
  if(document.implementation.hasFeature ("http://www.w3.org/TR/SVG11/feature#AnimationEventsAttribute", "1.0")) {
    document.getElementById("rotateSVG").style.display = "";
    document.getElementById("rotateFlash").style.display = "none";
  }
  else {
    document.getElementById("rotateSVG").style.display = "none";
    document.getElementById("rotateFlash").style.display = "";
  }
}
function supportsSvg() {
  if(document.implementation.hasFeature ("http://www.w3.org/TR/SVG11/feature#AnimationEventsAttribute", "1.0")) {
    document.getElementById("rotateSVG").style.display = "";
    document.getElementById("rotateFlash").style.display = "none";
  }
  else {
    document.getElementById("rotateSVG").style.display = "none";
    document.getElementById("rotateFlash").style.display = "";
  }
}