如何阻止滑鼠右鍵單擊 iframe 頂部,我嘗試在 iframe 標記中使用 oncontextmenu="return false" 但它不起作用,在我的情況下,我想更改頂部的右鍵我這樣做的pdf是iframe中的一個示例,這是我的代碼中的一個示例:
<html>
<head>
<title>block the right mouse</title>
</head>
<body >
<iframe oncontextmenu="return false" id="iframepdf" src="http://infolab.stanford.edu/pub/papers/google.pdf#toolbar=0" width="500px" height="600px" type="application/pdf"></iframe>
</body>
uj5u.com熱心網友回復:
這是禁用右鍵的完整代碼
<html>
<head>
<title>Disable Context Menu</title>
<script type="text/jscript">
function disableContextMenu()
{
window.frames["fraDisabled"].document.oncontextmenu = function()
{
alert("No way!");
return false;
};
}
</script>
</head>
<body bgcolor="#FFFFFF" onload="disableContextMenu();" oncontextmenu="return
false">
<iframe id="fraDisabled" width="528" height="473" src="local_file.html"
onload="disableContextMenu();" onMyLoad="disableContextMenu();">
</iframe>
</body>
</html>
我希望這是有用的......
uj5u.com熱心網友回復:
通過設計一個 IFrame 將背景關系移交給用戶系統,因此您幾乎沒有控制權,因為重點是它是為了用戶的利益。

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/481823.html
標籤:javascript html pdf 框架 前端
