1

出什么问题了

el.insertAdjacentHTML(hashVal[0], html);

其中 html 是"<a title=\"\">1</a>"并且hashVal[0]是“afterBegin”。

这与评级功能有关。我认为由于这个错误,在 ie 8 中没有显示评级星。其他浏览器都可以。我在下面给出了完整的代码流程。我正在使用 extjs。

 var starLink = star.createChild({
                tag: 'a',
                html: this.values[i],
                title: this.showTitles ? this.titles[i] : ''
            });

///////////////////////////////////////// ///////////////////////////////////////// ///////////////////////////////////////// //////////////

createChild : function(config, insertBefore, returnDom) {
         config = config || {tag:'div'};
         if (insertBefore) {
            return Ext.DomHelper.insertBefore(insertBefore, config, returnDom !== true);
         }
         else {
            return Ext.DomHelper[!this.dom.firstChild ? 'insertFirst' : 'append'](this.dom, config, returnDom !== true);
         }
    },

///////////////////////////////////////// ///////////////////////////////////////// ///////////////////////////////////////// //////////////

insertFirst : function(el, o, returnElement){
      return doInsert(el, o, returnElement, afterbegin, 'firstChild');
},

///////////////////////////////////////// ///////////////////////////////////////// ///////////////////////////////////////// //////////////

function doInsert(el, o, returnElement, pos, sibling, append){
        el = Ext.getDom(el);
        var newNode;
        if (pub.useDom) {
            newNode = createDom(o, null);
            if (append) {
                el.appendChild(newNode);
            } else {
                (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el);
            }
        } else {
            newNode = Ext.DomHelper.insertHtml(pos, el, Ext.DomHelper.createHtml(o));
        }
        return returnElement ? Ext.get(newNode, true) : newNode;
    }

///////////////////////////////////////// ///////////////////////////////////////// ///////////////////////////////////////// //////////////

function createHtml(o){
        var b = '',
            attr,
            val,
            key,
            cn,
            i;

        if(typeof o == "string"){
            b = o;
        } else if (Ext.isArray(o)) {
            for (i=0; i < o.length; i++) {
                if(o[i]) {
                    b += createHtml(o[i]);
                }
            }
        } else {
            b += '<' + (o.tag = o.tag || 'div');
            for (attr in o) {
                val = o[attr];
                if(!confRe.test(attr)){
                    if (typeof val == "object") {
                        b += ' ' + attr + '="';
                        for (key in val) {
                            b += key + ':' + val[key] + ';';
                        }
                        b += '"';
                    }else{
                        b += ' ' + ({cls : 'class', htmlFor : 'for'}[attr] || attr) + '="' + val + '"';
                    }
                }
            }

            if (emptyTags.test(o.tag)) {
                b += '/>';
            } else {
                b += '>';
                if ((cn = o.children || o.cn)) {
                    b += createHtml(cn);
                } else if(o.html){
                    b += o.html;
                }
                b += '</' + o.tag + '>';
            }
        }
        return b;
    }

///////////////////////////////////////// ///////////////////////////////////////// ///////////////////////////////////////// //////////////

 insertHtml : function(where, el, html){
            var hash = {},
                hashVal,
                range,
                rangeEl,
                setStart,
                frag,
                rs;

            where = where.toLowerCase();

            hash[beforebegin] = ['beforeBegin', 'previousSibling'];
            hash[afterend] = ['afterEnd', 'nextSibling'];


            if (el.insertAdjacentHTML) {
                if(tableRe.test(el.tagName) && (rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html))){
                    return rs;
                }


                hash[afterbegin] = ['afterBegin', 'firstChild'];
                hash[beforeend] = ['beforeEnd', 'lastChild'];
                if ((hashVal = hash[where])) {
                    el.insertAdjacentHTML(hashVal[0], html);
                    return el[hashVal[1]];
                }

            } else {
4

0 回答 0