2011-11-01 80 views
0

我試圖將光標更改爲具有音效的自定義圖像。我目前的問題是光標消失,但替換圖像不顯示,聲音剪輯沒有播放。我做錯了什麼?自定義光標與onclick音效

<head> 
<style type="text/css"> 
#apDiv1 { 
position:absolute; 
width:1152px; 
height:864px; 
z-index:2; 
left:25px; 
top:25px; 
} 
</style> 

<SCRIPT LANGUAGE="JavaScript"> 

function setCursor() { 
oBoxInner.innerText=sInput.value; 
oBoxInner.style.display='block'; 
oBox.style.cursor="crosshair.gif"; 
} 
</SCRIPT> 

<script language="javascript" type="text/javascript"> 
function playSound(soundfile) { 
document.getElementById("gunShot").innerHTML=document.getElementById("gunShot").innerHTML="<embed src=\""+gunshot.mp3+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />"; 
} 
</script> 

</head> 
<body bgcolor="#000000"> 

<div id="apDiv1"> 
<span id="gunShot" onclick="playSound('gunshot.mp3');"> 
<a href="3.html" onmouseover="setCursor" onmouseclick="playSound('gunshot.mp3')"> <img src="score.gif" width="1152" height="864" alt="yep" /> 
</a></span> 
</div> 

</body> 

謝謝您的幫助。

編輯:

我使用Dreamweaver的PC和Mac的多個瀏覽器的兼容性,主要是IE,火狐,Chrome和Safari。我在想.gif可能是問題的一部分,而不是.cur。我使用另一個光標代碼是這樣的:

<head> 
<script type="text/javascript"> 
$(document).ready(function(){ 
    $('#test-area').mouseout(function(){ 
     $('#mycursor').hide(); 
     return false; 
    }); 
    $('#test-area').mouseenter(function(){ 
     $('#mycursor').show(); 
     return false; 
    }); 
    $('#test-area').mousemove(function(e){ 
     $('#mycursor').css('left', e.clientX - 20).css('top', e.clientY + 7); 
    }); 
}); 
</script> 
<style type="text/css"> 
#test-area { 
    height: 1152px; 
    width:864px; 
    border: 3px dashed #CCCCCC; 
    background: #FFFFFF; 
    padding: 20px; 
    cursor: none; 
    top: 25px; 
    left: 25px; 
    z-index:1; 
} 
#mycursor { 
    cursor: none; 
    width: 100px; 
    height: 100px; 
    background: url(crosshairs.cur); 
    repeat: no-repeat; 
    position: absolute; 
    display: none; 
    top: 0; 
    left: 0; 
    z-index: 10000; 
} 
</style> 

</head> 

<body bgcolor="#000000"> 

    <div id="test-area"> 
     Move mouse over this area. 
    </div> 

    <div id="mycursor"> 
    </div> 

</body> 
+0

從哪裏定義oBox,哪些瀏覽器從 – david

+0

測試過oBoxInner和oBox都沒有定義。 WTH是'document.getElementById(「gunShot」)。innerHTML = document.getElementById(「gunShot」)。innerHTML' ??? –

+0

你正在使用'bgcolor =「#000000」'???停止這些並開始使用CSS。 –

回答

1

你在代碼

oBox了一些錯誤沒有定義。 oBox.style.cursor="crosshair.gif";

光標最好要.cur

embed標籤我只是想支持MIDI,和你引用您的oncick gunshot.mp3,並試圖在src調用reffrence到\""+gunshot.mp3+"\",應該是soundfile

你有TWICE?document.getElementById("gunShot").innerHTML=document.getElementById("gunShot").innerHTML

你想支持哪些瀏覽器的聲音? Netscape,IE6,Chrome ..等等