I am using an image scroller within Javascript, this is the code:
var step=1
function slideShow()
{
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slide.src=eval("image"+step+".src")
if (step<3)
step++
else
step=1
//call function "slideit()" every 2.0 seconds
setTimeout("slideShow()",2000)
}
slideShow()
It is required that this following code goes between the tags:
<script type="text/javascript">
<!--
var image1=new Image()
image1.src="images/image1.png"
var image2=new Image()
image2.src="images/image2.png"
var image3=new Image()
image3.src="images/image3.png"
var image4=new Image()
image4.src="images/image4.png"
var image5=new Image()
image5.src="images/image5.png"
//-->
</script>
Now, I have other Javascript files within an external js file. I have tried putting the whole code in with the others and hoping it carries with the tag, but it doesn't work. I have also tried adding it to an external one by itself, this also doesn't work.
I am sure it is something obvious, but I cannot think what. Anyone know?
I'd like to have all my JavaScript in JS docs.
Thanks.
要加载从外部.js文件内容,只保存在类似文件中的内容myJs.js
,然后将其包含在你的<head>
,像这样:
<script src="myJs.js" type="text/javscript" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.