禁用flash右键菜单

<script type="text/javascript">
function NoRightClick(pid) {
//pid:flash's parentNode id
var el = document.getElementById(pid);
if (el.addEventListener) {
el.addEventListener("mousedown", function (event) {
if (event.button == 2) {
event.stopPropagation(); //for firefox
event.preventDefault(); //for chrome
}
}, true);
} else {
el.attachEvent("onmousedown", function () {
if (event.button == 2) {
el.setCapture();
}
});
el.attachEvent("onmouseup", function () {
el.releaseCapture();
});
el.oncontextmenu = function () {
return false;
};
}
};
window.onload = function () {
NoRightClick("flashId");//flashId是你要禁用的flash播放器父级标签的id。注意:不是flash播放器的id。
}

比如:<div id="flashId">

<object id="flashContent">这里是flash播放器</object>

</div>

 

posted @ 2016-02-01 16:58  Cytran  阅读(379)  评论(0)    收藏  举报