全屏
長海網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,長海網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為長海近千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的長海做網(wǎng)站的公司定做!
var docElm = document.documentElement;
//W3C
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
}
//FireFox
else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
}
//Chrome等
else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
}
//IE11
else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
}
退出全屏
if (document.exitFullscreen) {
document.exitFullscreen();
}
else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
事件監(jiān)聽
document.addEventListener("fullscreenchange", function () {
fullscreenState.innerHTML = (document.fullscreen)? "" : "not ";}, false);
document.addEventListener("mozfullscreenchange", function () {
fullscreenState.innerHTML = (document.mozFullScreen)? "" : "not ";}, false);
document.addEventListener("webkitfullscreenchange", function () {
fullscreenState.innerHTML = (document.webkitIsFullScreen)? "" : "not ";}, false);
document.addEventListener("msfullscreenchange", function () {
fullscreenState.innerHTML = (document.msFullscreenElement)? "" : "not ";}, false);
全屏樣式設(shè)置
在瀏覽器全屏的使用我們還可以進(jìn)行樣式設(shè)置
html:-moz-full-screen {
background: red;
}
html:-webkit-full-screen {
background: red;
}
html:fullscreen {
background: red;
}
1、引入外部jquery文件
比如:
script?src="Scripts/jquery-1.3.2.min.js"?type="text/javascript"/script
2、點(diǎn)擊按鈕時(shí)的JQuery代碼
$(document).ready(function?()?{
$("#go").click(function?()?{???????
/*屬性*/???????
$("#go2").css({?"position":?"absolute",?"text-align":?"center",?"top":?"0px",?"left":?"0px",?"right":?"0px",?"bottom":?"0px",?"background":?"red",?"visibility":?"visible",?"filter":?"Alpha(opacity=90)"
});???????
/*高為屏幕的高*/???????
$("#go2").css({???????????
height:?function?()?{???????????
return?$(document).height();???????
},???????????
width:"100%"????????
});????
});
});
3、html頁面代碼
asp:Button?ID="go"?runat="server"?Style="width:?380px;?position:?absolute;?top:?249px;left:?425px;?background-color:?Green;?height:?65px;"?Text="后臺(tái)執(zhí)行程序,前臺(tái)遮蓋,運(yùn)行完畢后自動(dòng)消失"?/
div?id="go2"
正在提交數(shù)據(jù)...
/div
var?fullscreen=function(){
elem=document.body;
if(elem.webkitRequestFullScreen){
elem.webkitRequestFullScreen();?
}else?if(elem.mozRequestFullScreen){
elem.mozRequestFullScreen();
}else?if(elem.requestFullScreen){
elem.requestFullscreen();
}else{
//瀏覽器不支持全屏API或已被禁用
}
}
var?exitFullscreen=function(){
var?elem=document;
if(elem.webkitCancelFullScreen){
elem.webkitCancelFullScreen();?
}else?if(elem.mozCancelFullScreen){
elem.mozCancelFullScreen();
}else?if(elem.cancelFullScreen){
elem.cancelFullScreen();
}else?if(elem.exitFullscreen){
elem.exitFullscreen();
}else{
//瀏覽器不支持全屏API或已被禁用
}
}
需要注意,由于安全限制,需要由事件觸發(fā)fullscreen,比如綁定到某按鈕的單擊事件上。直接在控制臺(tái)調(diào)用可能無效。
IE的話可能不支持全屏API,原因大家都懂,在最后的else里面是提示還是使用window.open來實(shí)現(xiàn)你可以自己決定
有問題請(qǐng)追問。
$(window).scroll(function(event){
//滾動(dòng)即觸發(fā)
});
//$(window).scrollTop()這個(gè)方法是當(dāng)前滾動(dòng)條滾動(dòng)的距離
//$(window).height()獲取當(dāng)前窗體的高度
//$(document).height()獲取當(dāng)前文檔的高度
例:
配合如下使用,即可在滾動(dòng)是判斷是否到底部了;
var?bot?=?50;?//bot是底部距離的高度
if?((bot?+?$(window).scrollTop())?=?($(document).height()?-?$(window).height()))?{
//當(dāng)?shù)撞炕揪嚯x+滾動(dòng)的高度〉=文檔的高度-窗體的高度時(shí);
//我們需要去異步加載數(shù)據(jù)了
alert('我到底部了');
}