私のウィンドウが全幅になったらEscを押してください。ウィンドウが全幅でないときにカーソルを表示するには
次のコードを使用して、カーソルの表示/非表示とウィンドウの全幅の表示を行っています。
function toggleFullScreen(elem) {
if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
if (elem.requestFullScreen) {
elem.requestFullScreen();
document.body.style.cursor = 'none'; // to hide cursor
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
document.body.style.cursor = 'none'; // to hide cursor
} else if (elem.webkitRequestFullScreen) {
elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
document.body.style.cursor = 'none'; // to hide cursor
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
document.body.style.cursor = 'none'; // to hide cursor
}
} else{
document.body.style.cursor = 'default'; // to show cursor
console.log('test');
}
}
HTML:
<body oncontextmenu="return false;" onkeydown="return false;" onmousedown="return false;" onclick="toggleFullScreen(document.body)">
</body>
CSS:
body {
BACKGROUND: #000080;
color: #fff;
font-family: 'Yantramanav', sans-serif;
margin: 0 auto;
width: 100%;
padding: 0;
overflow:hidden;
}
どのようなエラーが発生していますか? – ihemant360
「あなたはexcボタンをクリックしたらどういう意味ですか?あなたのキーボードでエスケープキーを押すことについて話しているのですか、またはページにボタンがありますか? – Whothehellisthat
Nevermind - あなたはエスケープキーを意味すると思います。 Answer ...; D – Whothehellisthat