469,275 Members | 1,694 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Problem with DOM javascript with Firefox

1
Hello, everyone!

I have a javascript running perfectly with IE, but nothing seems to happend if I use firefox... anyone knows why?

Here is the script:
Expand|Select|Wrap|Line Numbers
  1. function add_div_field () {
  2.  
  3.     var ni = document.getElementById('upload_div');
  4.     var num = contador_upload++;
  5.     var div = document.createElement("div");
  6.     var div_name = "filediv"+num;
  7.     div.setAttribute("id",div_name);
  8.  
  9.     var table1 = document.createElement("<table width='100%' class='table0' border='0'>");
  10.  
  11.     var tbody1 = document.createElement("tbody");
  12.  
  13.     var tr1 = document.createElement("<tr width='100%' id='upload_table"+num+"'>");
  14.  
  15.  
  16.     var td1 = document.createElement("<td width='13'>");
  17.  
  18.  
  19.     var strong1 = document.createElement("strong");
  20.     var txtno = document.createTextNode(num+'.');
  21.  
  22.     strong1.appendChild(txtno);
  23.  
  24.     td1.appendChild(strong1);
  25.  
  26.     var td2 = document.createElement("<td width='700' valign='middle' class='grey_small'>");
  27.  
  28.  
  29.     var div2 = document.createElement("<div id='file"+num+"' class='showme'>");
  30.  
  31.  
  32.     var iframe = document.createElement("<iframe align='middle' marginheight='0' scrolling='no' marginwidth='0' frameborder='0' width='300' height='22' src='upload2.php?upload_id="+num+"'>");
  33.  
  34.  
  35.     div2.appendChild(iframe);
  36.  
  37.     var div3 = document.createElement("<div id='waiting"+num+"' class='hideme'>");
  38.  
  39.  
  40.     var txtwaiting = document.createTextNode('  Subiendo imagen, espera unos instantes...');
  41.     var br = document.createElement("br");
  42.  
  43.     var imgwaiting = document.createElement('<img src="pics/uploading.gif" width="220" height="19" align="absmiddle">');
  44.  
  45.  
  46.     div3.appendChild(txtwaiting);
  47.     div3.appendChild(br);
  48.     div3.appendChild(imgwaiting);
  49.  
  50.     var div4 = document.createElement("<div id='end_upload"+num+"' class='hideme'>");
  51.  
  52.  
  53.     var table2 = document.createElement("<table width='100%'>");
  54.  
  55.     var tbody2 = document.createElement("tbody");
  56.  
  57.     var tr2 = document.createElement("tr");
  58.  
  59.     var td3 = document.createElement("<td height='10'>");
  60.  
  61.     tr2.appendChild(td3);
  62.  
  63.     var tr3 = document.createElement("tr");
  64.     var td4 = document.createElement("td");
  65.     var txttitle = document.createTextNode("Título:");
  66.  
  67.     td4.appendChild(txttitle);
  68.     tr3.appendChild(td4);
  69.  
  70.     var tr4 = document.createElement("tr");
  71.     var td5 = document.createElement("td");
  72.  
  73.     var inputTitle = document.createElement("<input type='text' name='title["+num+"]' id='title["+num+"]'>");
  74.     var inputTitleName = "title["+num+"]";
  75.  
  76.     td5.appendChild(inputTitle);
  77.     tr4.appendChild(td5);
  78.  
  79.     var tr5 = document.createElement("tr");
  80.     var td6 = document.createElement("td");
  81.  
  82.     var txtdesc = document.createTextNode("Descripción Opcional:");
  83.  
  84.     td6.appendChild(txtdesc);
  85.     tr5.appendChild(td6);
  86.  
  87.     var tr6 = document.createElement("tr");
  88.     var td7 = document.createElement("td");
  89.  
  90.     var inputDesc = document.createElement("<textarea id='desc["+num+"]' name='desc["+num+"]' cols='40' rows='4'>");
  91.     var inputDescName = "desc["+num+"]";
  92.  
  93.     td7.appendChild(inputDesc);
  94.     tr6.appendChild(td7);
  95.  
  96.     var tr7 = document.createElement("tr");
  97.     var td8 = document.createElement("<td height='10'>");
  98.  
  99.     tr7.appendChild(td8);
  100.  
  101.     tbody2.appendChild(tr2);
  102.     tbody2.appendChild(tr3);
  103.     tbody2.appendChild(tr4);
  104.     tbody2.appendChild(tr5);
  105.     tbody2.appendChild(tr6);
  106.     tbody2.appendChild(tr7);
  107.  
  108.     table2.appendChild(tbody2);
  109.  
  110.     div4.appendChild(table2);
  111.  
  112.     td2.appendChild(div2);
  113.     td2.appendChild(div3);
  114.     td2.appendChild(div4);
  115.  
  116.     var td9 = document.createElement("<td width='21'>");
  117.  
  118.     var txtempty = document.createTextNode(" ");
  119.  
  120.     td9.appendChild(txtempty);
  121.  
  122.     var td10 = document.createElement("<td width='189'>");
  123.  
  124.     var imgphoto = document.createElement("<img src='pics/blank50x50.gif' id='photo"+num+"' name='photo"+num+"' width='50' height='50' class='upload_border'>");
  125.  
  126.     td10.appendChild(imgphoto);
  127.  
  128.     tr1.appendChild(td1);
  129.     tr1.appendChild(td2);
  130.     tr1.appendChild(td10);    
  131.  
  132.     tbody1.appendChild(tr1);
  133.  
  134.     table1.appendChild(tbody1);
  135.  
  136.     div.appendChild(table1);
  137.  
  138.     ni.appendChild(div);
  139.  
  140. }
Thanks!
May 17 '07 #1
1 3803
pbmods
5,821 Expert 4TB
Hello, everyone!

I have a javascript running perfectly with IE, but nothing seems to happend if I use firefox... anyone knows why?

Expand|Select|Wrap|Line Numbers
  1. var td1 = document.createElement("<td width='13'>");
  2.  
If I remember correctly, you can't pass HTML as an argument to document.createElement. In the case above, you would have to do this:

Expand|Select|Wrap|Line Numbers
  1. var td1 = document.createElement('td');
  2. td1.style.width = '13px';
  3.  
May 17 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Dave Blair | last post: by
3 posts views Thread by binnyva | last post: by
2 posts views Thread by John | last post: by
13 posts views Thread by Giggle Girl | last post: by
16 posts views Thread by Eric | last post: by
1 post views Thread by shidhincr | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.