html
<input type="text" id="myInput">
<h1 id="oo">我的第一个HTML页面</h1>
<p>我的第一个段落。</p>
JavaScript
const input = document.getElementById('myInput');
const oo = document.getElementById('oo');
oo.style.display = "block";
document.addEventListener('contextmenu', (event) => {
if (!input.contains(event.target)) {
event.preventDefault(); // 阻止默认菜单显示
if (oo.style.display === "none") {
oo.style.display = "block";
} else {
oo.style.display = "none";
}
}
});