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).
精彩评论