为什么这个Javascript代码在Google Chrome中不起作用

为什么这个Javascript代码在Google Chrome中不起作用,javascript,cross-browser,Javascript,Cross Browser,我在同一个网页上有类似的代码,google chrome可以很好地加载。但这个特殊的功能似乎只适用于某些浏览器。我自己找不到任何错误。也许我可以换一种方式写这份声明 <script type="text/JavaScript"> <!-- function changeWebsite() { var currentTime = new Date().getHours(); if (7 <= currentTime&&currentTime &l

我在同一个网页上有类似的代码,google chrome可以很好地加载。但这个特殊的功能似乎只适用于某些浏览器。我自己找不到任何错误。也许我可以换一种方式写这份声明

<script type="text/JavaScript">
<!--
function changeWebsite() {
var currentTime = new Date().getHours();    

 if (7 <= currentTime&&currentTime < 17) {
       document.write(' <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_VC01.png" width="200" height="45" alt=""> '); 

            document.write(' <a href="http://www.itsnotch.com" <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_VC02.png" width="200" height="75" border="0" alt="ItsNotch.com"></a> ');

        document.write(' <a href="http://www.notchtheguru.com" <img src="http://itsnotch.com/tumblr/images/NotchTheGuru.comVC.png" width="200" height="119" border="0" alt="Tumblr"></a>');


            document.write('<a href="http://www.bignotch.com" <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_VC04.png" width="200" height="161" border="0" alt="NotchTheGuru.com"></a>');
      }

       else {
       document.write(' <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_01.png" width="200" height="45" alt=""> '); 

            document.write(' <a href="http://www.itsnotch.com" <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_02.png" width="200" height="75" border="0" alt="ItsNotch.com"></a> ');

        document.write(' <a href="http://www.notchtheguru.com" <img src="http://itsnotch.com/tumblr/images/NotchTheGuru.com.png" width="200" height="119" border="0" alt="Tumblr"></a>');


            document.write('<a href="http://www.bignotch.com" <img src="http://itsnotch.com/tumblr/images/websitelist_tumblr_04.png" width="200" height="161" border="0" alt="NotchTheGuru.com"></a>');
      }

      }


changeWebsite();
-->
</script>

您缺少所有锚定标记上的结束括号。

代码工作正常,但您没有关闭开始锚定标记

<a href="http://www.notchtheguru.com" <img
应该是

<a href="http://www.notchtheguru.com"> <img

几乎所有那些document.write行都存在一个大问题,那就是它们都包含损坏的HTML代码

它们都有相同的问题,即在标记开始之前标记没有正确关闭-即缺少>

HTML中的这种语法错误很可能会产生跨浏览器渲染问题