简体   繁体   English

NotePad++ 和 JS?

[英]NotePad++ and JS?

I'm creating a web page with within the index.html a slideshow of 8 images.我在 index.html 中创建了一个包含 8 个图像的幻灯片的网页。 Now if I add these images, and I run it in a random browser it just works perfectly fine, while adding some javascripts to get a beautifull index page with a slideshow, it just does not do anything.现在,如果我添加这些图像,并在随机浏览器中运行它,它就可以正常工作,而添加一些 javascript 以获得带有幻灯片的漂亮索引页,它只是没有做任何事情。 I get a white page full of bugs etc. Can some one please tell me what I did do wrong?我得到了一个充满错误等的白页。有人可以告诉我我做错了什么吗?

 <html> <head> <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script type="text/javascript"> <!-- var img1 = new Image() img1.src ="F:\\Thema B\\website1\\img1.jpg" var img2 = new Image() img2.src ="F:\\Thema B\\website1\\img2.jpg" var img3 = new Image() img3.src ="F:\\Thema B\\website1\\img3.jpg" var img4 = new Image() img4.src ="F:\\Thema B\\website1\\img4.jpg" var img5 = new Image() img5.src ="F:\\Thema B\\website1\\img5.jpg" var img6 = new Image() img6.src ="F:\\Thema B\\website1\\img6.jpg" var img7 = new Image() img7.src ="F:\\Thema B\\website1\\img7.jpg" var img8 = new Image() img8.src ="F:\\Thema B\\website1\\img8.jpg" //--> </script> </head> <body> <img src="F:\\Thema B\\website1\\img.jpg" name="slide"> <script type="text/javascript"> <!-- var pic=1 function slides() { if (!document.images) return document.images.slide.src=eval("img"+pic+".src") if <pic < 8) pic++ else pic = 1 setTimeout("slides()",500) } slides() //--> </script> </body> </html>

So... at first glance, it looks like this line is the issue所以......乍一看,这条线似乎是问题所在

document.images.slide.src=eval("img"+pic+".src")

If you look, you are creating filenames of 'img1.src'.如果您看一下,您正在创建“img1.src”的文件名。 However, you actually want 'img1.jpg'.但是,您实际上想要“img1.jpg”。

Try this to fix the problem...试试这个来解决问题......

document.images.slide.src=eval("img"+pic+".jpg")

Also, you may likely need to put the full path there as well... so you may want to use something like此外,您可能还需要将完整路径放在那里......所以你可能想要使用类似的东西

document.images.slide.src=eval("F:\Thema B\website1\img"+pic+".jpg")

I see two problems:我看到两个问题:

1) there is a typo in if line. 1) if 行中有一个错字。 You typed你打字

if <pic < 8)

and i think you wanted我想你想要

if (pic < 8)

2) reading images from disk. 2)从磁盘读取图像。 Javascript blocks that due to security reasons出于安全原因,Javascript 会阻止

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

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