이것은 포럼에 대한 첫 번째 게시물입니다. 영어와 태국어로 된 많은 오디오 파일이 포함될 영어/태국어 코스 웹 사이트를 개설하고 있습니다. 마우스 오버/버튼 자바 스크립트 기능을 사용하여 단일 웹 페이지 증명을했습니다. http://www.javascriptkit.com/script/script2/soundlink.shtml 일부 개조 및 일부 인라인 j에서는이 작업이 정상적으로 수행되었습니다.jquery로 자바 스크립트 오디오 이동
$(document).ready(function() {
var html5_audiotypes = {
"mp3": "audio/mpeg",
"ogg": "audio/ogg",
};
function createsoundbite(sound) {
"use strict";
var html5audio = document.createElement('audio');
if (html5audio.canPlayType){
for(var i=0; i<arguments.length; i++) {
var sourceEl = document.createElement('source');
sourceEl.setAttribute('src', arguments[i]);
if (arguments[i].match(/\.(\w+)$/i))
sourceEl.setAttribute('type', html5_audiotypes[RegExp.$1]);
html5audio.appendChild(sourceEl);
}
html5audio.load();
html5audio.playclip = function() {
html5audio.pause();
html5audio.currentTime=0;
html5audio.play();
}
return html5audio;
}
else{
return {playclip:function(){throw new Error("Your browser doesn't support HTML5 audio unfortunately")}};
}
}
var cn402=createsoundbite("audio/cn402.ogg", "audio/cn402.mp3");
var ry402=createsoundbite("audio/ry402.ogg", "audio/ry402.mp3");
var cn403=createsoundbite("audio/cn403.ogg", "audio/cn403.mp3");
var ry403=createsoundbite("audio/ry403.ogg", "audio/ry403.mp3");
var cn404=createsoundbite("audio/cn404.ogg", "audio/cn404.mp3");
var ry404=createsoundbite("audio/ry404.ogg", "audio/ry404.mp3");
});
자바 스크립트 코드는이 같은 HTML 코드의 라인에 의해 호출된다
<a href="#current" class= "rollover" onclick="ry402.playclip()"></a>Please don't swim by yourself</span>
가 I이 JQuery와 기능에 관련 변수를 포함 할. 그래서 모든 js 코드가 html에서 제거됩니다. jquery 코드를 작동시키는 첫 번째 단계는 저에게 다소 문제가되는 것으로 판명되었습니다. 나는 그냥 문서 준비 기능에 js 오디오 코드를 포함 시키려고했다. 위와 같이 표시되지만 작동하지 않습니다. 어떤 도움이라도 대단히 감사 할 것입니다.
봐 :
것은 이제 살펴 보자 : //stackoverflow.com/questions/6830445/extending-jquery – Bart