0

所以我对javascript相当陌生。我想为该幻灯片中的每个图像添加一个链接。只有两个图像。我曾尝试像使用<a>in html 一样将它们链接起来……但这不起作用,因为它是 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: ""
})
4

1 回答 1

0

从数组的原始文档:imagearray

["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. 最后一个参数是将显示在图像底部的文本。

希望这可以帮助。

于 2012-12-31T22:59:53.430 回答