代码如下:
dTree.prototype.node = function(node, nodeId) { var str = '<div class="dTreeNode">' + this.indent(node, nodeId); if (this.config.useIcons) { if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node); if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node; if (this.root.id == node.pid) { node.icon = this.icon.root; node.iconOpen = this.icon.root; } str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />'; } if (node.url) {
if (!this.callbackfunction)
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
else
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="#"';
if (node.title) str += ' title="' + node.title + '"'; if (node.target) str += ' target="' + node.target + '"'; if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" '; if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
{
if (this.callbackfunction)
{
//str += ' onclick="displayFunc("'+node.url+'"); return false;"';
str += ' onclick="alert("?????????????"); return false;"';
}
else
str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
}
str += '>'; } else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id) str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">'; str += node.name; if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>'; str += '</div>'; if (node._hc) { str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">'; str += this.addNode(node); str += '</div>'; } this.aIndent.pop(); return str;};
会报错:Uncaught SyntaxError: Unexpected token } 
但是没有看见哪里有语法错误呀javascriptonclick无效

解决方案 »

  1.   

    会报错:Uncaught SyntaxError: Unexpected token }  难道没有行号吗
    自己仔细点
      

  2.   

    这个是在html文件调用js文件,行号显示的是html文件里面的
    用的chrome话说用document.write打印这种方式是不是存在问题?
      

  3.   

    哎 str += ' onclick="alert("?????????????"); return false;"';
    这句话的格式没问题呀,为啥返回后变成了 
    onclick="alert('?????????????');" return="" false;="" 
    百思不得其解............
      

  4.   


    str += ' onclick="alert(\"?????????????\"); return false;"';
      

  5.   

    擦 差点吐了,是双引号嵌套的问题,幸好一下想起C里面怎么将“”里面打印出“”来的方法。
    str += " onclick='alert(\"?????????????\"); return false;'";