问题描述
我的目标是创建一个新的网站,我需要制作一个全屏按钮,当用户点击它所有页面显示为全屏
什么我试过了:
我搜索它并且有我的尝试:
< ; input type =buttonvalue =click to toggle fullscreen>
< input type =buttonvalue =goto>
这是函数
函数toggleFullScreen(){
if((document.fullScreenElement&& document) .fullScreenElement!== null)||
(!document.mozFullScreen&&!document.webkitIsFullScreen)){
if(document.documentElement.requestFullScreen){
document.documentElement.requestFullScreen();
} else if(document.documentElement.mozRequestFullScreen){
document.documentElement.mozRequestFullScr een();
} else if(document.documentElement.webkitRequestFullScreen){
document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if(document.cancelFullScreen){
document.cancelFullScreen();
} else if(document.mozCancelFullScreen){
document.mozCancelFullScreen();
} else if(document.webkitCancelFullScreen){
document.webkitCancelFullScreen ();
}
}
}
函数func(){
window.location.replace(second.aspx);
}
这样可以在全屏显示页面,但问题是它何时重定向到第二页不支持全屏加载
这里是第二页的代码
document.addEventListener (DOMContentLoaded,函数(事件){
toggleFullScreen();
});
my问题现在有没有其他方法可以使所有网站从索引页面支持全屏模式?
I aim to create a new Website, I need to make a button of fullscreen, when user click it all pages showed as full screen
What I have tried:
I search it and there is my trying:
<input type="button" value="click to toggle fullscreen" >
<input type="button" value="goto" >
and this is function
function toggleFullScreen() {
if ((document.fullScreenElement && document.fullScreenElement !== null) ||
(!document.mozFullScreen && !document.webkitIsFullScreen)) {
if (document.documentElement.requestFullScreen) {
document.documentElement.requestFullScreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullScreen) {
document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}
}
function func() {
window.location.replace("second.aspx");
}
this works fine to show page in full screen but the problem is when it redirect to the second page it didn't support full screen on load
here is the code of second page
document.addEventListener("DOMContentLoaded", function (event) {
toggleFullScreen();
});
my question now is there any other way to make the all site support full screen mode from index page ?
推荐答案
这篇关于如何创建ASP网站支持全屏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!