What's wrong with this javascript? -


i'm using javascript switch out tables based on time. i'm getting error in dw.

       <script type="text/javascript"> <!-- function changewebsite() { var currenttime = new date().gethours();       if (7 <= currenttime&&currenttime < 18) {        document.write('  <table id="table_01" width="200" height="400" border="0" cellpadding="0" cellspacing="0">     <tr>         <td>             <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_vc01.png" width="200" height="45" alt=""></td>     </tr>     <tr>         <td>             <a href="http://www.itsnotch.com"                 onmouseover="window.status='visit biography website';  return true;"                 onmouseout="window.status='';  return true;">                 <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_vc02.png" width="200" height="75" border="0" alt="itsnotch.com"></a></td>     </tr>     <tr>         <td>             <a href="http://www.notchtheguru.com"                 onmouseover="window.status='my tumblr';  return true;"                 onmouseout="window.status='';  return true;">                 <img src="http://itsnotch.com/tumblr/images/notchtheguru.comvc.png" width="200" height="119" border="0" alt="tumblr"></a></td>     </tr>     <tr>         <td>             <a href="http://www.bignotch.com"                 onmouseover="window.status='welcome music website';  return true;"                 onmouseout="window.status='';  return true;">                 <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_vc04.png" width="200" height="161" border="0" alt="notchtheguru.com"></a></td>     </tr> </table> <br>  ');       }         else {        document.write(' <table id="table_01" width="200" height="400" border="0" cellpadding="0" cellspacing="0">     <tr>         <td>             <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_01.png" width="200" height="45" alt=""></td>     </tr>     <tr>         <td>             <a href="http://www.itsnotch.com"                 onmouseover="window.status='visit biography website';  return true;"                 onmouseout="window.status='';  return true;">                 <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_02.png" width="200" height="75" border="0" alt="itsnotch.com"></a></td>     </tr>     <tr>         <td>             <a href="http://www.notchtheguru.com"                 onmouseover="window.status='my tumblr';  return true;"                 onmouseout="window.status='';  return true;">                 <img src="http://itsnotch.com/tumblr/images/notchtheguru.com.png" width="200" height="119" border="0" alt="tumblr"></a></td>     </tr>     <tr>         <td>             <a href="http://www.bignotch.com"                 onmouseover="window.status='welcome music website';  return true;"                 onmouseout="window.status='';  return true;">                 <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_04.png" width="200" height="161" border="0" alt="notchtheguru.com"></a></td>     </tr> </table> <br>  ');       }  }  changewebsite(); --> 

the error on line 7 'document.write('

  1. javascript not support multiline strings.
  2. you have unescaped single quotes inside of string (which delimited single quotes).
    example, must change:

    onmouseover="window.status='visit biography website';  

    to:

    onmouseover="window.status=\'visit biography website\'; 

for detailed information, run code through jslint.

warning: jslint hurt feelings.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -