开发者

Change dimensions of body with JavaScript

开发者 https://www.devze.com 2023-01-18 06:18 出处:网络
How can I change the dimensions (width, height) of the body element after the content has been loaded?

How can I change the dimensions (width, height) of the body element after the content has been loaded?

Restrictions:

  • Only targeting WebKit browsers
  • Can't use frameworks like JQuery
  • Can't make changes to the original HTML file; 开发者_如何学JAVAonly execute JavaScript after the content has been loaded.


window.addEventListener("load", function() {
  document.body.style.width = '600px';
}, false);


You may use the onload JS event in your <body> tag. For example: <body onload="ResizeBody();">. And the function may look like this:

function ResizeBody() {
    document.body.style.width=your_width;
    document.body.style.height=your_height;
}

Now it works, sorry for the previous mistake (missing style in the tree).

0

精彩评论

暂无评论...
验证码 换一张
取 消