简体   繁体   English

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

[英]Javascript slideshow not working; works locally but not when uploaded

As the title suggests, the slideshow works locally but not when it's uploaded to the server. 顾名思义,幻灯片在本地工作,但在上传到服务器时不起作用。

The website is http://cmp.physics.iastate.edu/esl/photos.html 该网站是http://cmp.physics.iastate.edu/esl/photos.html

The slideshow code is: 幻灯片代码为:

<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>

Anyone have any idea or reason for why it is not working? 任何人有任何想法或原因为什么它不起作用?

Any help is appreciated. 任何帮助表示赞赏。 Thanks. 谢谢。

Your photos are missing see site errors: 您的照片丢失了,看到网站错误:

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

Ensure your pictures are in the correct location for images to show. 确保您的图片在正确的位置以显示图片。

I found this from the Console feature in Google Chrome , may I please suggest using this to develop and test sites. 我是从Google Chrome浏览器控制台功能中找到的,我可能建议您使用它来开发和测试网站。

Theck your javascript source file inclusion at in the body tag, You might have two jquery files included. 在body标签中包含javascript源文件,您可能会包含两个jquery文件。 I also faced this issue, it worked on my localhost but not on the live server, then i removed the second qquery inclusion and it started working. 我也遇到了这个问题,它可以在我的本地主机上运行,​​但不能在实时服务器上运行,然后我删除了第二个qquery包含项并开始工作。

I hope this works 我希望这能奏效

Example: 例:

<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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM