我似乎無法獲取IE8以防止執行onclick函數。嘗試了許多代碼變體。任何幫助,將不勝感激。現在,當我點擊鏈接時,我會看到不應該發生的警告彈出窗口。防止IE8中的onclick事件
<p><a href="#" onclick="openMoreProductVideos('Video title','videocode','false');return false;"><span class="txt">View all videos</span></a></p>
function openMoreProductVideos(title,productCode,fastprevoew)
{
alert ("openMoreProductVideos - should not see this!");
}
$('a[onclick^=openMoreProductVideos]').click(function (event) {
if (event.stopPropagation){
event.stopPropagation();
}
else if(window.event){
window.event.cancelBubble=true;
}
return false;
});
alert(event.stopPropagation);'show?爲什麼在代碼中需要兩個事件處理程序? –
[This](http://stackoverflow.com/questions/1756425/prevent-onclick-action-with-jquery/)將幫助和[this](http://stackoverflow.com/questions/387736/how-to -stop-event-propagation-with-inline-onclick-attribute /)too :) – Jashwant