
怎么用JS实现网站全屏
4个回答
2013-06-24
展开全部
那就用JS模拟按键F11实现吧!<html>
<head>
<title>JS模拟按键</title>
<script type="text/javascript">
function $(id){return document.getElementById(id)}
function loadListener(){
$("testBtn").onclick=function(){
var WshShell = new ActiveXObject('WScript.Shell')
WshShell.SendKeys('{F11}');
}
}
window.attachEvent("onload",loadListener);
</script>
<body>
我要实现这样一个效果:<br/>
当鼠标点击下面这个button时,就触发键盘按键事件,并且按下的键要为 F11,这样当前窗口就会全屏.<br/>
<input type="button" id="testBtn" value="点我全屏化">
</body>
</head>
</html>
<head>
<title>JS模拟按键</title>
<script type="text/javascript">
function $(id){return document.getElementById(id)}
function loadListener(){
$("testBtn").onclick=function(){
var WshShell = new ActiveXObject('WScript.Shell')
WshShell.SendKeys('{F11}');
}
}
window.attachEvent("onload",loadListener);
</script>
<body>
我要实现这样一个效果:<br/>
当鼠标点击下面这个button时,就触发键盘按键事件,并且按下的键要为 F11,这样当前窗口就会全屏.<br/>
<input type="button" id="testBtn" value="点我全屏化">
</body>
</head>
</html>
2013-06-24
展开全部
JS实现不了!需要使用FLASH或Silverlight
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-24
展开全部
上面提供的JS就算有点效果,也只是在IE内核浏览器下面,其他浏览器都无效
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-24
展开全部
获取屏幕的大小:
window.screen.width 宽
window.screen.height 高
然后 :
window.moveTo(0,0);
window.resizeTo(屏幕宽,屏幕高)
代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript" src="smAjax.js"></script>
<script language="javascript">
function Init()
{
window.moveTo(0,0);
window.resizeTo(window.screen.width,window.screen.height);
}
</script>
</head>
<body onload="Init()">
</body>
</html>
window.screen.width 宽
window.screen.height 高
然后 :
window.moveTo(0,0);
window.resizeTo(屏幕宽,屏幕高)
代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript" src="smAjax.js"></script>
<script language="javascript">
function Init()
{
window.moveTo(0,0);
window.resizeTo(window.screen.width,window.screen.height);
}
</script>
</head>
<body onload="Init()">
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询