日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

body onload 控制窗口大小 html,如何实现在调整浏览器窗口大小时缩放的网页?

發布時間:2023/12/1 HTML 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 body onload 控制窗口大小 html,如何实现在调整浏览器窗口大小时缩放的网页? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

感謝所有的建議!看起來我必須做的丑陋的東西是必要的。以下工作(在我的機器上,無論如何)在IE和FireFox中。我稍后可以為CodeProject.com制作一篇文章; - )

這個javascript進入< head>部分:

var tmout = null;

var mustReload = false;

function Resizing()

{

if (tmout != null)

{

clearTimeout(tmout);

}

tmout = setTimeout(RefreshAll,300);

}

function Reload()

{

document.location.href = document.location.href;

}

//IE fires the window's onresize event when the client area

//expands or contracts, which causes an infinite loop.

//the way around this is a hidden div set to 100% of

//height and width, with a guard around the resize event

//handler to see if the _window_ size really changed

var windowHeight;

var windowWidth;

window.onresize = null;

window.onresize = function()

{

var backdropDiv = document.getElementById("divBackdrop");

if (windowHeight != backdropDiv.offsetHeight ||

windowWidth != backdropDiv.offsetWidth)

{

//if screen is shrinking, must reload to get correct sizes

if (windowHeight != backdropDiv.offsetHeight ||

windowWidth != backdropDiv.offsetWidth)

{

mustReload = true;

}

else

{

mustReload = mustReload || false;

}

windowHeight = backdropDiv.offsetHeight;

windowWidth = backdropDiv.offsetWidth;

Resizing();

}

}

< body>像這樣開始:

style="width:100%; clear:both; height: 100%; margin: 0;

padding: 0; position:absolute; top:0px; left:0px;

visibility:hidden; z-index:0;">

DIV向左浮動以進行布局。我必須將高度和寬度設置為完全量(例如,99.99%,59.99%,39.99%)的百分比,以防止浮動包裹,可能是由于DIV上的邊界。

最后,在內容部分之后,另一個javascript塊來管理刷新:

var isWorking = false;

var currentEntity = ;

//try to detect a bad back-button usage;

//if the current entity id does not match the querystring

//parameter entityid=###

if (location.search != null && location.search.indexOf("&entityid=") > 0)

{

var urlId = location.search.substring(

location.search.indexOf("&entityid=")+10);

if (urlId.indexOf("&") > 0)

{

urlId = urlId.substring(0,urlId.indexOf("&"));

}

if (currentEntity != urlId)

{

mustReload = true;

}

}

//a friendly please wait... hidden div

var pleaseWaitDiv = document.getElementById("divPleaseWait");

//an example content div being refreshed via AJAX PRO

var contentDiv = document.getElementById("contentDiv");

//synchronous refresh of content

function RefreshAll()

{

if (isWorking) { return; } //no infinite recursion please!

isWorking = true;

pleaseWaitDiv.style.visibility = "visible";

if (mustReload)

{

Reload();

}

else

{

contentDiv.innerHTML = NAMESPACE.REFRESH_METHOD(

(currentEntity, contentDiv.offsetWidth,

contentDiv.offsetHeight).value;

}

pleaseWaitDiv.style.visibility = "hidden";

isWorking = false;

if (tmout != null)

{

clearTimeout(tmout);

}

}

var tmout2 = null;

var refreshInterval = 60000;

//periodic synchronous refresh of all content

function Refreshing()

{

RefreshAll();

if (tmout2 != null)

{

clearTimeout(tmout2);

tmout2 = setTimeout(Refreshing,refreshInterval);

}

}

//start periodic refresh of content

tmout2 = setTimeout(Refreshing,refreshInterval);

//clean up

window.onunload = function()

{

isWorking = true;

if (tmout != null)

{

clearTimeout(tmout);

tmout = null;

}

if (tmout2 != null)

{

clearTimeout(tmout2);

tmout2 = null;

}

很丑,但它確實有效 - 我猜它真正重要; - )

總結

以上是生活随笔為你收集整理的body onload 控制窗口大小 html,如何实现在调整浏览器窗口大小时缩放的网页?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。