![](/img/trans.png)
[英]Webkit-Transform:Scale doesn't work in HTML5 FullScreen mode (chrome only)
[英]Can't type any letters or numbers in text inputs in fullscreen mode on webkit browsers
切換到全屏模式(在chrome和safari上測試)后,我無法在文本輸入中鍵入任何字母或數字,但我仍然可以輸入特殊字符,如*¨%£
但沒有簡單的字母......
代碼非常簡單:
HTML
<button type="button" id="fullScreen">LAUNCH FULLSCREEN</button>
<input type="text" />
JS
function launchFullScreen(element) {
if(element.requestFullScreen) {
element.requestFullScreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
}
}
document.getElementById("fullScreen").addEventListener("mousedown", function(){
launchFullScreen(document.documentElement);
}, false);
正如Jan Dvorak所提到的,只有在使用js函數時才會出現問題,使用瀏覽器內置全屏按鈕/快捷方式時不會出現錯誤
看到它的實際效果:
http://jsfiddle.net/QwqT7/show/
更新2:
剛剛在Firefox for Mac上測試過,在全屏模式下沒有問題。 似乎問題只是webkit。
這不是一個完美的解決方案,但至少它可以讓Chrome響應鍵盤命令,讓Safari使用全屏模式,無需鍵輸入作為后備。
function launchFullScreen(element) {
if(element.requestFullScreen) {
element.requestFullScreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)){
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
setTimeout(function() {
if (!document.webkitCurrentFullScreenElement && element.webkitRequestFullScreen()) {
element.webkitRequestFullScreen();
}
},100);
}
出於安全原因,大多數鍵盤輸入已在全屏模式下被阻止。 但是,在Google Chrome中,您可以通過使用標記調用方法來請求鍵盤支持...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.