Javascript 与图像Onmouseover关联的传递链接

Javascript 与图像Onmouseover关联的传递链接,javascript,Javascript,我需要将与5个不同图像关联的链接动态传递到不同的图像。我已经创建了更改图像的函数,但这是我无法找到答案的最后一部分。以下是我目前的代码: <html> <head><title>Revolving Pictures</title> <script type="text/javascript"> function changeBigPic(newPic){ var big

我需要将与5个不同图像关联的链接动态传递到不同的图像。我已经创建了更改图像的函数,但这是我无法找到答案的最后一部分。以下是我目前的代码:

<html>
<head><title>Revolving Pictures</title>
   <script type="text/javascript">          
        function changeBigPic(newPic){
            var big = document.getElementById("bigPic");
            big.src = newPic;
    //***How do I get the href of the 'album' images to 'bigPic'? I'm also trying to double the size of bigPic and using 200% makes the image enormous! Thanks in advance   
}
    </script>
</head>
    <body>
        <img name="bigPic" id="bigPic" src="album1.jpg" height="200%" width="200%"><br />

<A HREF="http://stevenseagal.com/"><img src="album1.jpg" id="segal" onmouseover="changeBigPic(document.getElementById('segal').src);">

&nbsp <A HREF="http://www.richardcheese.com/" target="_blank"><img src="album2.jpg" id="cheese" onmouseover="changeBigPic(document.getElementById('cheese').src);">

&nbsp <A HREF="http://www.myspace.com/etjusticepourtous" target="_blank"><img src="album3.jpg" id="justice" onmouseover="changeBigPic(document.getElementById('justice').src);">

&nbsp <A HREF="http://www.bestcoast.us/" target="_blank"><img src="album4.jpg" id="bestCoast" onmouseover="changeBigPic(document.getElementById('bestCoast').src);">

&nbsp <A HREF="http://www.van-halen.com/" target="_blank"><img src="album5.jpg"       id="vanHalen" onmouseover="changeBigPic(document.getElementById(this.id).src);">

 </body>
<html>

旋转图片
函数changeBigPic(newPic){
var big=document.getElementById(“bigPic”);
big.src=newPic;
//***如何将“相册”图像的href设置为“bigPic”?我还尝试将bigPic的大小增加一倍,使用200%将图像放大!提前感谢
}

       
我认为最简单的方法是传递img对象,而不是只传递其源

将onmouseover替换为
onmouseover=“changeBigPic(this);”
,新的changeBigPic函数如下所示:

function changeBigPic(element){
    var big = document.getElementById("bigPic");
    big.src = element.src;

    // To get the href of the parent node:
    var href = element.parentNode.href;
}

好的,第一部分现在开始工作了。然后我添加了一行:big.parentnode.href=href;在“bigPic”之前,firebug说函数中“big.parentnode未定义”。另外,big.style.height*=2;&大.style.width*=2;也无法更改大小。感谢advanceDOM属性,例如
parentNode
区分大小写
big.parentNode.href=href工作正常。我没有注意到,但是HTML文档中有很多错误:最后的标记必须以正斜杠(
)开头,并且
img
a
标记也必须关闭。你可以在网上得到更多的细节。关于更改大小,如果您知道第一幅图像的大小,只需输入原始值而不是“200%”,您可以使用
big.style.width=2*element.width;big.style.height=2*element.height。