日期:2014-05-16  浏览次数:20360 次

浏览器锁频功能javascript代码
//浏览器锁频功能javascript代码,网上搜集,测试时效果没出来,不知道怎么回事,如果正常了,再贴完整的解决代码
function showScreen(id) {
//var Element = document.getElementById(id);
var Elements = document.getElementById("Screen");
alert(getWidth());
Elements.style.width = getWidth();
alert(getHeight());
Elements.style.height = getHeight();
//Element.style.display = "block";
Elements.style.display = "block";
}

function hideScreen(id) {
var Element = document.getElementById(id);
var Elements = document.getElementById("Screen");
Element.style.display = "none";
Elements.style.display = "none";
}

function getWidth() {
var strWidth, clientWidth, bodyWidth;
clientWidth = document.documentElement.clientWidth;
bodyWidth = document.body.clientWidth;
if (bodyWidth > clientWidth) {
strWidth = bodyWidth + 20;
} else {
strWidth = clientWidth;
}
return strWidth;
}
function getHeight() {
var strHeight, clientHeight, bodyHeight;
clientHeight = document.documentElement.clientHeight;
bodyHeight = document.body.clientHeight;
if (bodyHeight > clientHeight) {
strHeight = bodyHeight + 50;
} else {
strHeight = clientHeight + 50;
}
return strHeight;
}

//以下是对应的div

<div id="Screen" style="position:absolute;z-index: 9999;top: 0px;left: 0px;background:#CCC;display: none;filter: alpha(Opacity=1);">锁屏测试</div>