I need compatible JavaScript code for document.createElementNS() in older versions of IE

后端 未结 1 487
暗喜
暗喜 2021-01-20 08:58

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

相关标签:
1条回答
  • 2021-01-20 09:27

    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');
            // ...
        });
    };
    
    0 讨论(0)
提交回复
热议问题