Javascript幻灯片无法正常工作;在本地工作但在上传时不工作

时间:2013-10-13 18:22:38

标签: javascript html web slideshow

正如标题所示,幻灯片在本地运行,但在上传到服务器时则不然。

网站为http://cmp.physics.iastate.edu/esl/photos.html

幻灯片代码为:

<script type="text/javascript">
<!-->
    var image1=new Image()
    image1.src="images/ESL Keep/Thumbnails/IMG_2509.jpg"
    var image2=new Image()
    image2.src="images/ESL Keep/Thumbnails/IMG_2510.jpg"
    var image3=new Image()
    image3.src="images/ESL Keep/Thumbnails/IMG_2518.jpg"
    var image4=new Image()
    image4.src="images/ESL Keep/Thumbnails/IMG_2536.jpg"
    var image5=new Image()
    image5.src="images/ESL Keep/Thumbnails/IMG_2537.jpg"
    var image6=new Image()
    image6.src="images/ESL Keep/Thumbnails/IMG_2537.jpg"
    var image7=new Image()
    image7.src="images/ESL Keep/Thumbnails/IMG_2543.jpg"
//-->
</script>
<img src="images/ESL Keep/Thumbnails/IMG_2509.jpg" name="slide" width="450" height="300"/>
<script type="text/javascript">
<!--
    var step=1
    function slideit(){
        document.images.slide.src=eval("image"+step+".src")
        if(step<6)
            step++
        else
            step=1
        setTimeout("slideit()",3000)
    }
    slideit();
//-->
</script>

任何人都有任何想法或理由说明为什么它不起作用?

感谢任何帮助。感谢。

2 个答案:

答案 0 :(得分:0)

您的照片丢失,请参阅网站错误:

Failed to load resource: the server responded with a status of 404 (Not Found) http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2509.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2510.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2518.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2536.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2537.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2543.jpg
GET http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2510.jpg 404 (Not Found) photos.html:78
GET http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2518.jpg 404 (Not Found) photos.html:78
GET http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2536.jpg 404 (Not Found) photos.html:78
GET http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2537.jpg 404 (Not Found) photos.html:78
GET http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2537.jpg 404 (Not Found) photos.html:78
GET http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2509.jpg 404 (Not Found) photos.html:78
GET http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2510.jpg 404 (Not Found) photos.html:78
GET http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2518.jpg 404 (Not Found) photos.html:78
GET http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2536.jpg 404 (Not Found) photos.html:78
GET http://cmp.physics.iastate.edu/esl/images/ESL%20Keep/Thumbnails/IMG_2537.jpg 404 (Not Found) photos.html:78

确保您的照片位于正确的位置,以便显示图像。

我是从Console feature in Google Chrome发现的,我建议您使用它来开发和测试网站。

答案 1 :(得分:0)

将您的javascript源文件包含在body标签中,您可能包含两个jquery文件。我也遇到过这个问题,它在我的本地主机上工作但在实时服务器上没有,然后我删除了第二个qquery包含它开始工作了。

我希望这有效

示例:

<body>
    <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="js/jquery-1.1.0.min.js"></script>
    <!--find the second jquery file and remove it-->
    </body