Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Animation 检测对beginElement()的支持_Animation_Svg_Internet Explorer 9_Modernizr_Feature Detection - Fatal编程技术网

Animation 检测对beginElement()的支持

Animation 检测对beginElement()的支持,animation,svg,internet-explorer-9,modernizr,feature-detection,Animation,Svg,Internet Explorer 9,Modernizr,Feature Detection,我正在使用beginElement()在我的web应用程序中启动SVG动画: document.getElementById("item").beginElement(); 但这会在IE9及以上版本中导致以下错误: 我不介意动画不能在IE9中工作,但是我需要防止错误的发生。如何设置检查,以便仅在浏览器支持时调用beginElement()?例如: if (hasSupport) { document.getElementById("item").beginElement(); } 我

我正在使用
beginElement()
在我的web应用程序中启动SVG动画:

document.getElementById("item").beginElement();
但这会在IE9及以上版本中导致以下错误:

我不介意动画不能在IE9中工作,但是我需要防止错误的发生。如何设置检查,以便仅在浏览器支持时调用
beginElement()
?例如:

if (hasSupport) {
    document.getElementById("item").beginElement();
}
我尝试了一种检测技术:

但它总是返回
false
,即使在我知道支持它的浏览器中(比如Firefox)


我还研究了使用,但它没有对
beginElement()

进行测试。您可以在执行该方法之前嗅探它是否存在

var item = document.getElementById("item");

if ('beginElement' in item) {
    item.beginElement();
}
Modernizer以的形式使用
,但是
if(item.beginElement)
的工作原理是一样的。

Modernizer有一个测试,您可以使用它,尽管它有点通用。但是,如果SMIL也不受支持,那么检查
beginElement
就没有实际意义。
return !!document.getElementById("item").beginElement();
var item = document.getElementById("item");

if ('beginElement' in item) {
    item.beginElement();
}