如何在Javascript幻灯片中链接个别图像?

时间:2012-12-31 22:31:07

标签: javascript image hyperlink slideshow

所以我对javascript很新。我想在此幻灯片中添加指向每个图像的链接。只有两个图像。我试图像你在html中使用<a>那样链接它们......但是这不起作用,因为它是Javascript。是否有一行简单的代码可用于将Javascript幻灯片中的每个单独图像链接到不同的站点?非常感谢。任何反馈都非常感谢。

这是我的代码。感谢来自dynamicdrive.com的帮助

var mygallery=new fadeSlideShow({
    wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
    dimensions: [1024, 511], //width/height of gallery in pixels. Should reflect dimensions of largest image
    imagearray: [
        ["../Images/slideshow_wakeup.png"],
        ["../Images/slideshow_2.png"]
        <!--["newappvantagemobile.com/images/slideshow_3.png"]-->
         //<--no trailing comma after very last image element!
    ],
    displaymode: {type:'auto', pause:4500, cycles:0, wraparound:false},
    persist: false, //remember last viewed slide and recall within same session?
    fadeduration: 900, //transition duration (milliseconds)
    descreveal: "ondemand",
    togglerid: ""
})

1 个答案:

答案 0 :(得分:1)

来自imagearray数组的original documentation

["path_to_image", "optional_url", "optional_linktarget", "optional_description"]

因此您需要将imagearray数组更改为:

imagearray: [
         ["../Images/slideshow_wakeup.png"], "../Images/slideshow_wakeup.png", "_new", "Some text to describe the image."],
        ["../Images/slideshow_2.png", "../Images/slideshow_2.png", "_new", "Some text to describe the image."],
        <!--["newappvantagemobile.com/images/slideshow_3.png"]-->
         //<--no trailing comma after very last image element!
    ],

我会解释一下。该数组有4个元素。

  1. 第一个是图像的地址(如您所知)。
  2. 第二个是单击图像时将打开的链接。
  3. 第三个指定链接的打开方式。 _new表示新窗口/标签
  4. 最后一个参数是将显示在图像底部的文本。
  5. 希望这有帮助。