单击按钮时播放音频,并在播放完声音后重定向

编程入门 行业动态 更新时间:2024-10-28 06:37:02
本文介绍了单击按钮时播放音频,并在播放完声音后重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我用四个按钮制作了一个简单的网站。如果我单击一个,我希望它播放声音,当声音播放完毕后(或在 X秒后),我希望它重定向。

I made I simple site with four buttons. If I click one I want it to play a sound and when the sound is done playing (or after 'X' amount of seconds) I want it to redirect.

此到目前为止是我的代码。我不知道如何添加声音和延迟。

This is my code so far. I have no idea on how to put in the sound and the delay.

<html> <head> <link rel="stylesheet" type="text/css" href="/level1/style.css"> </head> <body> <img STYLE= "top: 20px; Left: 200px; height:900px; width: 800px position: absolute;" src="\images\border.jpg"> <img STYLE= "position: absolute; top: 50px; Left: 50px; height:120px; width: 120px;" src="\images\level1.jpg"> <a href="#"><img src="\images\1a1.jpg" onmouseover="this.src='/images/1a1g.jpg'" onmouseout="this.src='/images/1a1.jpg'" id="a1"> </a> <a href="\level1\index.html"><img src="\images\1a2.jpg" onmouseover="this.src='/images/1a2g.jpg'" onmouseout="this.src='/images/1a2.jpg'" " id="a2"> </a> <a href="\level1\index.html"><img src="\images\1a3.jpg" onmouseover="this.src='/images/1a3g.jpg'" onmouseout="this.src='/images/1a3.jpg'" id="a3"> </a> <a href="\level1\index.html"><img src="\images\1a4.jpg" onmouseover="this.src='/images/1a4g.jpg'" onmouseout="this.src='/images/1a4.jpg'" id="a4"> </a> </body> </html>

推荐答案

您需要嵌入HTML音频元素: www.w3schools/tags/ref_av_dom.asp

You need to embed a HTML Audio Element:www.w3schools/tags/ref_av_dom.asp

使用eventlistener中的play()方法,如本页中所述,可以在音频播放结束后启动音频: www.w3schools/tags/av_event_ended.asp 您可以通过以下方式设置超时时间:

With the method play() in the eventlistener, as described on this page you can start the audio, when Audio playing has ended: www.w3schools/tags/av_event_ended.asp You can set a Timeout with

`var seconds= 3; setTimeout( function(){ /* This code will be executed, after the defined Delay */ } seconds * 1000);`

更多推荐

单击按钮时播放音频,并在播放完声音后重定向

本文发布于:2023-07-11 09:36:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093603.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:并在   单击   重定向   按钮   音频

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!