javascript程式碼:
function get_page_size()
🎜>var re = {};
if (document.documentElement && document.documentElement.clientHeight)
{
var doc = document.documentElement;
re.width = (doc.width =doc. .scrollWidth)?doc.clientWidth-1:doc.scrollWidth;
re.height = (doc.clientHeight>doc.scrollHeight)?doc.clientHeight:doc.scrollHeight;
}
else
else
{
var doc = document.body;
re.width = (window.innerWidth>doc.scrollWidth)?window.innerWidth:doc.scrollWidth;
re.height = (window.innerHeight>doc. scrollHeight)?window.innerHeight:doc.scrollHeight;
}
返回re;
}
904 瀏覽了3 則留言
程式碼
實例
>
取得視窗大小
function getPageSize()
{
var re = {};
if (document.documentElement && document.documentElement.clientHeight)
{
var doc = document.documentElement;
re.width = (doc.clientWidth>doc.scrollWidth)?doc.clientWidth-1:doc.scrollWidth;
re.height = (doc. clientHeight>doc.scrollHeight)?doc.clientHeight:doc.scrollHeight;
}
else
{
var doc = document.body;
re.width = (window.innerWidth>doc.in .scrollWidth)?window.innerWidth:doc.scrollWidth;
re.height = (window.innerHeight>doc.scrollHeight)?window.innerHeight:doc.scrollHeight;
}
//結果輸出至兩個文字框
document.form1.availHeight.value= re.width;
document.form1.availWidth.value= re.height;
返回重新;
}
腳本>>
頭>