如何在Javascript幻灯片中链接个别图像? [英] How to link individual images in Javascript Slideshow?
问题描述
所以我对javascript很新。我想在此幻灯片中添加指向每个图像的链接。只有两个图像。我试图像在html中使用< a>
一样链接它们但是这不起作用,因为它是Javascript。是否有一行简单的代码可用于将Javascript幻灯片中的每个单独图像链接到不同的站点?非常感谢。任何反馈都非常感谢。
So I am fairly new to javascript. I would like to add a link to each of the images in this slideshow. There are only two images. I have tried to link them like you would with an <a>
in html...but that didn't work since it's Javascript. Is there a simple line of code that I could add to link each individual image in a Javascript slideshow to different sites? Thanks so much. Any feedback is much appreciated.
这是我的代码。感谢来自dynamicdrive.com的帮助
Here is my code. Thanks to help from 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: ""
})
推荐答案
来自 imagearray 数组的eshow.htmrel =nofollow>原始文档:
From the original documentation of the imagearray
array:
["path_to_image", "optional_url", "optional_linktarget", "optional_description"]
所以你需要将 imagearray
数组更改为:
So you need to change the imagearray
array to this:
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个元素。
I'll explain it. The array has 4 elements.
- 第一个是图像的地址(如您所知)。
- 第二个是单击图像时将打开的链接。
- 第三个指定链接的打开方式。
_new
表示在新窗口/选项卡上 - 最后一个参数是将显示在图像底部的文本。
- First one is the address of the image (as you know already).
- Second one is the link which will be opened when you click on the image.
- Third one specifies how the link will be opened.
_new
means on a new window/tab - The last parameter is the text which will be shown at the bottom of the image.
希望这会有所帮助。
这篇关于如何在Javascript幻灯片中链接个别图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!