javascript:如何檢測HTML img元素支持SVG?javascript:如何檢測HTML img元素支持SVG?
我嘗試這樣做,但它不工作:
x = new Image();
x.onload = function(){
if (x.width) {
alert('svg in img tag supported!');
}
};
x.src = 'test.svg';
javascript:如何檢測HTML img元素支持SVG?javascript:如何檢測HTML img元素支持SVG?
我嘗試這樣做,但它不工作:
x = new Image();
x.onload = function(){
if (x.width) {
alert('svg in img tag supported!');
}
};
x.src = 'test.svg';
的方法商量好/比較是在這裏: http://www.voormedia.nl/blog/2012/10/displaying-and-detecting-support-for-svg-images
基於在該網頁上,我結束了使用此:
svgsupport = document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1")
重複的http://stackoverflow.com/問題/ 4118254 /可靠 - 檢測-img-tag-support-for-svg – jbeard4 2011-02-16 03:45:22
它不是重複的,這裏我回答「img標籤中的svg」,而不是「inline svg in html5」 – Yaffle 2011-03-23 18:28:44