이 기사에서는 JS가 웹 배경 음악의 재생 및 정지를 어떻게 제어하는지 설명합니다. 참조를 위해 공유하십시오. 특정 구현 방법은 다음과 같습니다.
코드를 다음과 같이 복사하십시오.
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<meta http-equiv = "content-type"content = "text /html; charset = gb2312" />
<title> JS 배경 음악을 제어하는 방법 bgsound (시작 및 중지) </title>
</head>
<body>
<script type = "text/javaScript">
var bg_sound = document.createelement_x ( "bgsound"); // 배경 음악 생성
bg_sound.id = "i_bg"// ID 속성을 설정합니다
document.body.appendchild (bg_sound); // 신체에 배경 음악 추가
//bg_sound.src="tmp3.mp3 ";
i_bg.src = "tmp3.mp3"; // 배경 음악 파일을 설정합니다
// write로 작성해야합니다. 효과를 시도 할 수 있습니다.
함수 bg_stop () {
i_bg.src = "";
}
함수 bg_start () {
i_bg.src = "tmp3.mp3";
}
</스크립트>
<span> <a onclick = "JavaScript : bg_stop ();" href = "javaScript : void (0);"> 배경 음악 정지 </a> </span> <span> a onclick = "javaScript : bg_start ();" href = "javaScript : void (0);"> 배경 음악 시작 </a> </span>
</body>
</html>
이 기사가 모든 사람의 JavaScript 프로그래밍에 도움이되기를 바랍니다.