| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2187 人关注过本帖
标题:极度简单的代码,就是不能运行,求大神阅一下!
只看楼主 加入收藏
freebirdbo
Rank: 1
等 级:新手上路
帖 子:256
专家分:0
注 册:2005-3-27
收藏
 问题点数:0 回复次数:2 
极度简单的代码,就是不能运行,求大神阅一下!
<html>
<head>
<title>Audio</title>
<script>
function playSound(src){
var _s = document.getElementById('snd');
if(src!='' && typeof src!=undefined){
_s.src = src;
}
}
</script>
</head>
<body>
<input id="snd" type="button" value="play" onclick="playSound('http://mp3.')">
</body>
</html>
2016-02-26 22:42
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
收藏
得分:0 
程序代码:
<!DOCTYPE html>
<html> 
<head> 
<title>Audio</title> 
<meta charset="utf-8">
<script>
function playSound(s)  //由于javascript对变量特别敏感,_s.src = src;看起来不妥。
{
    var _s = document.getElementById('txt');
    if(s!='' && typeof(s)!='undefined')  //typeof(s)
    {
        _s.innerHTML = s;  //替换p中的文字
    }
}
</script>
</head> 
<body> 
<input id="snd" type="button" value="play" onclick="playSound('http://mp3.')">
<p id="txt">111111</p>
</body> 
</html>

   唯实惟新 至诚致志
2016-02-26 23:43
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
<!DOCTYPE html>

<html>
<head>
    <title>Audio</title>
    <script>
        function playSound(src) {
            var s = document.getElementById('snd');
            if (src != '' && typeof src != undefined) {
                s.src = src;
            }
            s.play();
        }
    </script>
</head>
<body>
    <video id="snd"></video>
    <input type="button" value="play" onclick="playSound('Hero.mp3')">
</body>
</html>

请注意以下几点:
1、播放MP3需要video标签
2、播放MP3需要调用video标签的play方法

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2016-03-01 14:47
快速回复:极度简单的代码,就是不能运行,求大神阅一下!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022931 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved