发现现在我们做的浏览器支持以下格式:
function getHtmlForButton(nameStr, str, bClass,onClickFn){
    if(nameStr == null || nameStr ==""
      || str == null || str ==""
      || onClickFn == null || onClickFn =="") {
        debugMsg("One of the input params for the button is not available");
        return;
    }
    document.writeln('<input type="button" name="'+nameStr+'" value="'+str+'" class="'+bClass+'"  onClick="'+onClickFn+'">');
}但如果换成:
function getHtmlForButton(nameStr, str, bClass,onClickFn){
    if(nameStr == null || nameStr ==""
      || str == null || str ==""
      || onClickFn == null || onClickFn =="") {
        debugMsg("One of the input params for the button is not available");
        return;
    }
    document.writeln('<input type="button" name="',nameStr,'" value="',str,'" class="',bClass,'"  onClick="',onClickFn,'">');
}
document.writeln调用参数时的'+',换成','就不支持了. input button就显示不出来。
但其它浏览器(IE,Firefox OK).谁知道这种语法都各在哪个版本的javascript 标准支持的。 最好能给出相关的specification的文档。
我需要知道一个参考。谁能给出答案我多多送分。java script

解决方案 »

  1.   

    这标准不楚
    一个高效通用的做法是
    var htmls=[];
     htmls.push("xxx");
    htmls.push("1","2",...);
    .....
    document.write( html.join("") );
    //这样比字符+拼接速度快灵活,也比一个个document.write快
      

  2.   

    javascript,
    即ECMAScript,此可看做javascript标准
    百度下就有
      

  3.   

    对,手上有ECMAscript的标准,但找不到对这种语法的定义。
      

  4.   

    http://www.w3school.com.cn/htmldom/met_doc_write.asp
    自己看第二种方法标准里面不支持,但根据经验浏览器会支持,只是你那个很多参数都不是合法的html,所以输出失败
      

  5.   

    ECMA262标准5.1 2011年
    http://www.ecma-international.org/publications/standards/Ecma-262.htm
    中间有一段
    The grammar for a ConditionalExpression in ECMAScript is a little bit different from that in C and Java, which each allow the second subexpression to be an Expression but restrict the third expression to be a ConditionalExpression. The motivation for this difference in ECMAScript is to allow an assignment expression to be governed by either arm of a conditional and to eliminate the confusing and fairly useless case of a comma expression as the centre expression.
    貌似允许使用逗号表达式。
      

  6.   

    原来钻牛角尖去了,只想着怎么改解析算法,让遇到‘,’号的时候能够把后面的参数取出来加到原来的字串里面去。
    wzs_xyz兄给的那个连接给了我很大启示。已经修改java script引擎里面的wirte和writeln函数让它们支持多个参数。工作正常了。