`
qiujiayu
  • 浏览: 170273 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

IE8 innerHTML-未知的运行时错误

 
阅读更多

最近在使用 jquery.zclip.1.1.1,但用IE8测试时发现 报“未知的运行时错误”。

 

        // create floating DIV above element

        this.div = document.createElement('div');

        this.div.className = "zclip";

        this.div.id = "zclip-" + this.movieId;

        $(this.domElement).data('zclipId', 'zclip-' + this.movieId);

        var style = this.div.style;

        style.position = 'absolute';

        style.left = '' + box.left + 'px';

        style.top = '' + box.top + 'px';

        style.width = '' + box.width + 'px';

        style.height = '' + box.height + 'px';

        style.zIndex = zIndex;

 

        if (typeof(stylesToAdd) == 'object') {

            for (addedStyle in stylesToAdd) {

                style[addedStyle] = stylesToAdd[addedStyle];

            }

        }

 

        // style.backgroundColor = '#f00'; // debug

        appendElem.appendChild(this.div);

 

        this.div.innerHTML = this.getHTML(box.width, box.height);// 这行报错

 

    后来改成:

 

 // create floating DIV above element

        this.div = document.createElement('div');

        this.div.className = "zclip";

        this.div.id = "zclip-" + this.movieId;

        $(this.domElement).data('zclipId', 'zclip-' + this.movieId);

        var style = this.div.style;

        style.position = 'absolute';

        style.left = '' + box.left + 'px';

        style.top = '' + box.top + 'px';

        style.width = '' + box.width + 'px';

        style.height = '' + box.height + 'px';

        style.zIndex = zIndex;

 

        if (typeof(stylesToAdd) == 'object') {

            for (addedStyle in stylesToAdd) {

                style[addedStyle] = stylesToAdd[addedStyle];

            }

        }

        this.div.innerHTML = this.getHTML(box.width, box.height);

        // style.backgroundColor = '#f00'; // debug

        appendElem.appendChild(this.div);

 

这样就不会报错了。至于出错原因,还没想到,希望有高人指点。

 

        

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics