如何消除domexception:元素没有支持的源。 [英] How to eliminate domexception: the element has no supported sources.
本文介绍了如何消除domexception:元素没有支持的源。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< head runat = server >
< title > < / title >
< script >
function PlaySound(soundobj){
var thissound = document .getElementById(soundobj);
thissound.play();
}
功能 PauseSound(soundobj){
< span class =code-keyword> var thissound = document .getElementById(soundobj);
thissound.pause();
}
< / script >
< / head >
< ; 正文 >
< audio id = audio1 src = Sounds / DPM317.wav 控件 = 控件 preload = auto > < / audio >
< audio id = audio2 src = 声音/ DS250069new.wav 控件 = 控制 preload = auto > < / audio >
< 表格 id = form1 runat = 服务器 >
< div >
< 输入 type = 按钮 value = PlaySound onclick = PlaySound('audio1'),PlaySound('audio2') / >
< 输入 类型 = 按钮 value = PauseSound onclick = PauseSound('audio2'),PauseSound('audio1') / >
< / div >
< / form >
< / body >
以上是我的完整代码,用于在Chrome浏览器中播放.wav文件,但在开发人员工具中调试时,我看到
<附近的错误span class =code-keyword>< input type = 按钮 value = PlaySound onclick = PlaySound('audio1'),PlaySound('audio2') / >
< 输入 类型 = 按钮 value = PauseSound onclick = PauseSound('audio2'),PauseSound('audio1') / >
和 thissound.play();
和 thissound.pause();
我该如何解决这个问题?
我尝试了什么:
我尝试了上面的代码,但它给了我错误
解决方案
< blockquote> HI,
看看这个例子。它的工作没有错误。
xszaboj的钢笔 [ ^ ]
我认为您的问题可能是您的路径对第一个或第二个wav文件不正确。
<head runat="server">
<title></title>
<script>
function PlaySound(soundobj) {
var thissound = document.getElementById(soundobj);
thissound.play();
}
function PauseSound(soundobj) {
var thissound = document.getElementById(soundobj);
thissound.pause();
}
</script>
</head>
<body>
<audio id="audio1" src="Sounds/DPM317.wav" controls="controls" preload="auto"></audio>
<audio id="audio2" src="Sounds/DS250069new.wav" controls="controls" preload="auto"></audio>
<form id="form1" runat="server">
<div>
<input type="button" value="PlaySound" onclick="PlaySound('audio1'), PlaySound('audio2')" />
<input type="button" value="PauseSound" onclick="PauseSound('audio2'), PauseSound('audio1')" />
</div>
</form>
</body>
Above is my complete code which is used to play .wav files in chrome browser but when debugging in developer tools i am seeing the error near
<input type="button" value="PlaySound" onclick="PlaySound('audio1'), PlaySound('audio2')" />
<input type="button" value="PauseSound" onclick="PauseSound('audio2'), PauseSound('audio1')" />
and thissound.play();
and thissound.pause();
how can i solve this?
What I have tried:
I tried the above code but it gives me errors
解决方案
HI,
have a look on this example. It works without error.
A Pen by xszaboj[^]
I think your problem could be that your path is not correct to either first or second wav file.
这篇关于如何消除domexception:元素没有支持的源。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文