Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 动态html对齐在Chrome中不正确,但在IE和FF中工作良好_Javascript_Html - Fatal编程技术网

Javascript 动态html对齐在Chrome中不正确,但在IE和FF中工作良好

Javascript 动态html对齐在Chrome中不正确,但在IE和FF中工作良好,javascript,html,Javascript,Html,下面是我使用内部Html创建表的代码。在IE和Firefox中,输入框的对齐方式很好,但在Chrome中,它会向后显示。我不知道这个代码有什么问题 如果您有任何建议,我将不胜感激 function insertRow(){ var pricingType = window.dialogArguments.getAttribute('pricingType'); var srcTable = document.getElementById("priceTabl

下面是我使用内部Html创建表的代码。在IE和Firefox中,输入框的对齐方式很好,但在Chrome中,它会向后显示。我不知道这个代码有什么问题

如果您有任何建议,我将不胜感激

function insertRow(){    

    var pricingType = window.dialogArguments.getAttribute('pricingType');    
      var srcTable = document.getElementById("priceTable"); 
      var tmpRow = null;
      var tmpCell = null;

      var inp1 =  document.createElement("INPUT");
      var inp2 =  document.createElement("INPUT");
      var inp3 =  document.createElement("INPUT");
      var inp4 =  document.createElement("INPUT");
      var inp5 =  document.createElement("INPUT");

      inp1.setAttribute("type","text");
      inp2.setAttribute("type","text");
      inp3.setAttribute("type","text");
      inp4.setAttribute("type","text");
      inp5.setAttribute("type","text");  

      tmpRow = AppendRow(srcTable);
      tmpRow.setAttribute("borderColor","white");     
      tmpCell = AppendCell(tmpRow);
      tmpCell.innerHTML = "<font color=red>* denotes required fields";
      tmpCell.setAttribute("colSpan","2");      
      tmpCell = null;
      tmpRow = null;

    tmpRow = AppendRow(srcTable);
      tmpRow.setAttribute("borderColor","white");

      tmpCell = AppendCell(tmpRow);
      tmpCell.innerHTML = "<b>*Price Qty";
      tmpCell = null;

      if(pricingType == 'T'){             
            tmpCell = AppendCell(tmpRow);
            tmpCell.innerHTML = "<b>*Tier Price";
            tmpCell = null;
      }
      if(pricingType == 'B'){       
            tmpCell = AppendCell(tmpRow);
            tmpCell.innerHTML = "<b>*Bracket Price";
            tmpCell = null;
      }
      tmpRow = null;

      tmpRow = AppendRow(srcTable);
      tmpRow.setAttribute("borderColor","white");

      tmpCell = AppendCell(tmpRow);             
      tmpCell.appendChild(inp1);    
      inp1.setAttribute("name","priceQty");     
      inp1.setAttribute("id","priceQty");
      inp1.setAttribute("value","");
      tmpCell = null;

      tmpCell = AppendCell(tmpRow);
      tmpCell.appendChild(inp2);    
      inp2.setAttribute("name","price");
      inp2.setAttribute("id","price");
      inp2.setAttribute("value","");
      tmpCell = null;
      tmpRow = null;

      tmpRow = AppendRow(srcTable);
      tmpRow.setAttribute("borderColor","white");

      tmpCell = AppendCell(tmpRow);
      tmpCell.innerHTML = "<b>*PriceStartDate(e.g. 06/12/2007)";
      tmpCell = null;

      tmpCell = AppendCell(tmpRow);
      tmpCell.innerHTML = "<b>PriceEndDate(e.g. 06/12/2007)";
      tmpCell = null;   
      tmpRow = null;

      tmpRow = AppendRow(srcTable);
      tmpRow.setAttribute("borderColor","white");     

      tmpCell = AppendCell(tmpRow);
      tmpCell.appendChild(inp3);    
      inp3.setAttribute("name","priceStartDate");
      inp3.setAttribute("id","priceStartDate");
      inp3.setAttribute("value","");
      tmpCell = null;

      tmpCell = AppendCell(tmpRow);
      tmpCell.appendChild(inp4);    
      inp4.setAttribute("name","priceEndDate");
      inp4.setAttribute("id","priceEndDate");
      inp4.setAttribute("value","");
      tmpCell = null;
      tmpRow = null;

      tmpRow = AppendRow(srcTable);
      tmpRow.setAttribute("borderColor","white");

      tmpCell = AppendCell(tmpRow);
      tmpCell.innerHTML = "<b>*Created By";
      tmpCell = null;
      tmpRow = null;

      tmpRow = AppendRow(srcTable);
      tmpRow.setAttribute("borderColor","white");

      tmpCell = AppendCell(tmpRow);             
      tmpCell.appendChild(inp5);    
      inp5.setAttribute("name","createUserId"); 
      inp5.setAttribute("id","createUserId");
      inp5.setAttribute("value","");
      tmpCell = null;
      tmpRow = null;

}

//AppendRow JS funcation

function AppendRow(srcTable)
{
    if(srcTable != null)
    {
        return srcTable.insertRow();
    }
    else
    {
        alert("Error while creating table. Cause: Container Table is null!");
    }
}

//AppendCell JS funcation
function AppendCell(srcRow)
{
    if(srcRow != null)
    {
        return srcRow.insertCell();
    }
    else
    {
        alert("Error while creating table. Cause: Container row is null!");
    }
}
Chrome是否存在内部html问题?

从AppendRow返回新创建的行,如下所示:返回srcTable.insertRow-1

如果省略了,浏览器会以不同的方式定位插入的行。传递-1会将新创建的行始终追加到表的末尾