Why am I getting Unexpected token illegal in javascript? -


why getting error "unexpected token illegal" in script? script supposed retrieve cookies , display names , values in table. error occurs on line has opening table tag.

document.getelementbyid("showcookies").onclick = function(){          var columnright = document.getelementbyid('columnright');          var cookies = document.cookie;         var cookiescontent = '<h1>existing cookies</h1>';         console.log(cookies);         cookies = cookies.split(";");          if(cookies.length > 0){              cookiescontent += '<table width="30%" cellspacing="1" cellpadding="10" border="0">             <thead>                 <tr>                     <th>name</th>                     <th>value</th>                 </tr>             </thead>             <tbody>                 ';              for(var = 0; < cookies.length; i++){                  cookieatts = cookies[i].split('=');                 cookiescontent += "<tr><td>" + cookieatts[0] + "</td><td>" + cookieatts[1] + "</td></tr>";              }              cookiescontent += "</tbody></table>";          }          columnright.innerhtml = cookiescontent;          return false;     } 

it's because can't have multiline strings in javascript without backslashes:

cookiescontent += '<table width="30%" cellspacing="1" cellpadding="10" border="0"> \             <thead> \                 <tr> \                     <th>name</th> \                     <th>value</th> \                 </tr> \             </thead> \             <tbody> \                 '; 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -