对于那些不知道的人,本机全屏是您的浏览器占据整个计算机屏幕的地方,就像在这个例子中一样。我制作了一个可以运行的全屏 JavaScript 应用程序,但默认情况下,Chrome 和 Firefox 以不同的方式打开本机全屏。Firefox 会拉伸对象,使其占据整个屏幕(高度 100%,宽度 100%),而 Chrome 会将对象放在具有自然比例的黑色背景前。
我希望 Firefox 在 Chrome 上表现得像全屏。我觉得这可以通过简单的 CSS 更改来解决,但我不太了解 CSS。
这是我迄今为止尝试过的:
<!DOCTYPE html>
<html>
<head>
<style>
.fsElement:-webkit-full-screen {
//this is the CSS for Chrome's fullscreen page
}
.fsElement:-moz-full-screen {
//this is the CSS for Firefox's fullscreen page
}
</style>
</head>
<body>
<script type="text/javascript">
function goFullscreen(id) {
// Get the element that we want to take into fullscreen mode
var element = document.getElementById(id);
// These function will not exist in the browsers that don't support fullscreen mode yet,
// so we'll have to check to see if they're available before calling them.
if (element.mozRequestFullScreen) {
// This is how to go into fullscren mode in Firefox
element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
// This is how to go into fullscreen mode in Chrome and Safari
// Both of those browsers are based on the Webkit project, hence the same prefix.
element.webkitRequestFullScreen();
}
// Hooray, now we're in fullscreen mode!
}
</script>
<img class="fsElement" height="375" width="500" src="http://s3.amazonaws.com/rapgenius/filepicker%2FvCleswcKTpuRXKptjOPo_kitten.jpg" id="kittenPic"></img>
<br />
<button onclick="goFullscreen('kittenPic'); return false">Click Me To Go Fullscreen!</button>
</body>
</html>
提前致谢!