实现窗口真正全屏的函数

博客给出了一段JavaScript代码,用于实现窗口真正全屏的功能。代码根据不同的浏览器(Netscape、Microsoft Internet Explorer)和操作系统(Mac、Windows)进行判断,采用不同的方式打开窗口以达到全屏效果,并给出了函数调用示例。

//实现窗口真正全屏的函数
//以下代码保存为"js.js"

function fullscreen(url, wname ) {
var URLen=url;
var windowNamen=wname;
var browserName=navigator.appName;
var operatingSystem=navigator.platform;
var version = parseFloat(navigator.appVersion);

// Netscape check version 4.0+ on Win
if (browserName.indexOf("Netscape")!=-1 && version>=4.0 && operatingSystem.indexOf("Mac")!=-1)
{
window.open(URLen,windowNamen,'titlebar=no,top=0,left=0,width=' + window.screen.availWidth+',height='+window.screen.availWidth+',screenX=0,screenY=0,top=0,left=0')
}

// MSIE Mac check
else if (browserName.indexOf("Microsoft Internet Explorer")!=-1 && operatingSystem.indexOf("Mac")!=-1)
{
window.open(URLen,windowNamen,'titlebar=no,top=0,left=0,width=' + window.screen.availWidth+',height='+window.screen.availWidth+',screenX=0,screenY=0,top=0,left=0')
}

// Netscape Mac check
else if (browserName.indexOf("Netscape")!=-1 && operatingSystem.indexOf("Mac")!=-1)
{
window.open(URLen,windowNamen,'width='+screen.width+',height='+screen.height+',top=0,left=0');
}

// MSIE Windows
else if (browserName.indexOf("Microsoft Internet Explorer")!=-1 && operatingSystem.indexOf("Win")!=-1)
{
//window.open(URLen,windowNamen,'fullscreen=1,top=0,left=0');
var win = window.open(URLen,windowNamen,'titlebar=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,fullscreen=1,top=0,left=0,width=' + window.screen.availWidth+',height='+window.screen.availHeight+',screenX=0,screenY=10,top=0,left=0')
win.resizeTo(screen.width, screen.height);
}

// Netscape Windows
else if (browserName.indexOf("Netscape")!=-1 && operatingSystem.indexOf("Win")!=-1)
{
window.open(URLen,windowNamen,'width='+screen.width+',height='+screen.height+',top=0,left=0');
}

else
{
window.open(URLen,windowNamen);
}

}

<!--函数调用-->

<script language="JavaScript" src="js.js"></script>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值