html打开播放声音的新标签 [英] html open new tab with playing sound

查看:137
本文介绍了html打开播放声音的新标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何打开新标签页。例如,这就是我所拥有的:

I know how to open a new tab. For example, this is what I have:

<a href="pdfs/award_2.pdf" target="_blank" style="font-size:17px">Award</a></span>

此代码将打开一个新标签,并加载我的award_2.pdf文件。但是,当打开新标签时,我怎么能做一些播放音乐的东西呢?我怎么能这样做,当我关闭新标签时,音乐也停止了?

This code, will open a new tab, and loads my award_2.pdf file. But how can I also do something that it plays a music also when the new tab is opened? And how can I make such that when I close the new tab, the music stops as well?

我也有音频标签代码:

<audio id="audio1_3"><source src="sounds/audio1_3.mp3" type="audio/mpeg" /><source src="sounds/audio1_3.ogg" type="audio/ogg" />Your browser does not support the audio element.</audio>

但是如何通过打开/关闭pdf文件来进行播放/停止?

But how can I make this plays/stops by opening/closing the pdf file?

推荐答案

在pdf文件所在的同一文件夹中创建一个新的html文件,并将此代码放在该html文件中。

Create a new html file in the same folder where is your pdf file located and put this code in that html file.

 <audio autoplay>
  <source src="youraudio.ogg" type="audio/ogg">
  <source src="youraudio.mp3" type="audio/mp3">
  Your browser does not support the audio element.
</audio> 
   <iframe id="viewer" src="yourpdffile.pdf" allowfullscreen="" webkitallowfullscreen="" height="500" width="700"></iframe>

保存文件(根据需要更改代码中的路径)。
将锚点指向新的html文件。

save the file(change path in the code as necessary). Point the Anchor to the new html file.

<a href="newhtmlfile.html" target="_blank" style="font-size:17px">Award</a></span>

就是这样。

这篇关于html打开播放声音的新标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆