我需要在早期版本的IE中为document.createElementNS()提供兼容的JavaScript代码 [英] I need compatible JavaScript code for document.createElementNS() in older versions of IE

查看:83
本文介绍了我需要在早期版本的IE中为document.createElementNS()提供兼容的JavaScript代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JavaScript函数 document.createElementNS() 在旧版IE(6,7,8)中不起作用?该函数是否有任何兼容代码,例如 Array 兼容的地图功能旧版IE?

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?

推荐答案

看看以下谷歌小组发布。有一种解决方法可以帮助您:
http:// code .google.com / p / svgweb / issues / detail?id = 625

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');
        // ...
    });
};

这篇关于我需要在早期版本的IE中为document.createElementNS()提供兼容的JavaScript代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆