首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >向Shadowbox JS库添加函数

向Shadowbox JS库添加函数
EN

Stack Overflow用户
提问于 2014-01-29 05:06:37
回答 1查看 217关注 0票数 0

我设置了一个用于显示图像的太空箱画廊。但是,除了下一步、上一步和关闭按钮之外,我还想添加一个音频按钮,以便播放与每张照片相关的mp3文件。这个是可能的吗?这是我为图片准备的HTML代码...

代码语言:javascript
运行
复制
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<script type="text/javascript" src="Script/jquery.js"></script> 
<link rel="stylesheet" type="text/css" href="Styles/shadowbox.css">
<script type="text/javascript" src="Script/shadowbox.js"></script>
<script type="text/javascript">

Shadowbox.init();
    window.onload = function() {
        Shadowbox.open({
            content:    'Images/Tech_trends_img/memory_capacity.png', 
            player: "img",
            title:  "Figure.1: Memory Capacity",
            gallery:    "TechTrends",
        });
    };
</script>

</head>

<body>

<div id="menu" style="display: none;">  
    <ul>
        <li><a rel="shadowbox[TechTrends]" href="Images/Tech_trends_img/processor_capacity.png" title="Figure.2: Processor Capacity"></a></li>      
        <li><a rel="shadowbox[TechTrends]" href="Images/Tech_trends_img/processor_capacity_2.png" title="Figure.3: Processor Capacity"></a></li>
        <li><a rel="shadowbox[TechTrends]" href="Images/Tech_trends_img/processor_performance.png" title="Figure.4: Processor Performance"></a></li>        
        <li><a rel="shadowbox[TechTrends]" href="Images/Tech_trends_img/post_1990.png" title="Figure.5: Processor Capacity Post 1990"></a></li>     
        <li><a rel="shadowbox[TechTrends]" href="Images/Tech_trends_img/processor_clk_rate.png" title="Figure.6: Processor Clock Rate">\</a></li>   
        <li><a rel="shadowbox[TechTrends]" href="Images/Tech_trends_img/physical_limits_moore.png" title="Figure.7: Physical Limits on Moore's Law"></a></li>   
    </ul>
</div>
EN

回答 1

Stack Overflow用户

发布于 2014-01-29 10:44:51

使用此按钮添加音频按钮。

代码语言:javascript
运行
复制
<!DOCTYPE html>
<script type="text/javascript">
function listen(){
var audio = document.getElementById("audio");
audio.currentTime = 0;
audio.play();
}
</script>

<audio preload="auto" id="audio">
  <source src="YOURAUDIOFILE.ogg" type="audio/ogg">
  <source src="YOURAUDIOFILE.mp3" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio> 
<input type="button" value="Listen"  onclick="listen()">
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21416828

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档