-4
我想有一些超链接图像,在一段时间后不断变化..我使用了2个数组图像和链接.. 2个相应的功能分别在2秒后执行更改图像和链接。但是,我得到一个空白屏幕output..I写的代码为:图像交换超链接
<html>
<head>
<title> New Document </title>
</head>
<body>
<img id="img" width="1300" height="200"/>
<link id="link" >
<script type="text/javascript">
var x=0;
var y=0;
var images = new Array();
var links = new Array();
images[0] = "D:\images\31.jpg";
images[1] = "D:\images\32.jpg";
links[0] = "https://www.google.co.in" ;
links[1] = "https://www.facebook.com" ;
function changeImage()
{
document.getElementById("img").src=images[x];
x = (x + 1) % images.length;
}
function changeLinks()
{
document.getElementById("link").href=links[y];
y = (y + 1) % links.length;
}
window.onload = function() {
changeImage();
setInterval(changeImage,2000);
}
window.onload = function() {
changeLinks();
setInterval(changeLinks,2000);
}
</script>
</body>
</html>
可以üplz阐述..什么是在你的代码行中的文件?..和在哪里给“\\”? – user2335676 2013-04-30 11:59:12
查看更多关于在Javascript中转义字符的内容:http://www.w3schools.com/js/js_obj_string.asp JS中的基本字符串转义! – Liv 2013-04-30 12:00:36
更好地复制/移动图像到服务器路径并使用像'../ images/31.jpg'这样的相对路径。使用文件url并指向磁盘并不是最佳选择。 – Appleshell 2013-04-30 12:01:36