The JavaScript function document.createElementNS()
does not work in older versions of IE (6,7,8)? Is there any compatible code for this function, like Array
's compatible map function for old version IE?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Have a look at the following google group post. There's a workaround that may help you: http://code.google.com/p/svgweb/issues/detail?id=625
Workaround (from link above):
window.onload = function() {
function onCreateElementNsReady(func) {
if (document.createElementNS != undefined) {
func();
} else {
setTimeout(function() { onCreateElementNsReady(func); }, 100);
}
}
onCreateElementNsReady(function() {
var svg = document.createElementNS(svgns, 'svg');
// ...
});
};