将超链接添加到 JavaScript 图像数组

Adding hyperlinks to a javascript image array

本文关键字:图像 数组 JavaScript 超链接 添加      更新时间:2023-09-26

我在使用java轮播时遇到了问题。代码在我的页面上运行良好,但我想向图像添加超链接,但我不确定如何实现这一点。我已经尝试了一些方法,但它只是导致代码停止工作,并且轮播从页面上掉落。

正如我所说,它一切正常,但是一旦我更改默认代码,它就会动摇。

到目前为止,我的代码是:

<script type="text/javascript">
var firstbgcarousel=new bgCarousel({
    wrapperid: 'mybgcarousel', //ID of blank DIV on page to house carousel 
    imagearray: [
        ['autumnpark.jpg', '<h2>Autumn Day</h2>The sun peaks through the trees, a knife that cuts through the chill, crisp air.'], //["image_path", "optional description"]
        ['chime.jpg', '<h2>Wind Chime</h2>The bellweather of the sky, the chime speaks of impending turmoil.'],
        ['girlportrait.jpg', 'The scent of spring invigorates her as she inhales whilst the warm breeze brings a wave of tranquility.'],
        ['redbench.jpg', 'Alone and Lonliness- Peace and Inner Struggle'] //<--no trailing comma after very last image element!
    ],
    displaymode: {type:'auto', pause:3000, cycles:2, stoponclick:false, pauseonmouseover:true},
    navbuttons: ['left.gif', 'right.gif', 'up.gif', 'down.gif'], // path to nav images
    activeslideclass: 'selectedslide', // CSS class that gets added to currently shown DIV slide
    orientation: 'h', //Valid values: "h" or "v"
    persist: true, //remember last viewed slide and recall within same session?
    slideduration: 500 //transition duration (milliseconds)
})
</script>

任何帮助不胜感激。

在这里查看源代码:http://home.comcast.net/~jscheuer1/side/bgcarousel/demo_linked.htm

很好的例子。只需在幻灯片文本中添加一个链接,并使用 CSS 将其样式设置为幻灯片框的宽度和高度 100%。