I have a few client sites that have a width of about 900px-1000px centered, using javascript how can I find out what the actual width of the document is? I don't need to know the width of the window, just the width that the actual html document is using.
I also can't use any div id's to find it. I know I can use jquery for this, but I'd like to use plain javascript as jquery isn't running on all the sites.
In jquery, I can find this out by using:
$('body').outerWidth(true)
Can someone help?
var body = document.getElementsByTag("body")[0];
var width = body.style.width;
another option:
var body = document.getElementsByTag("body")[0];
var width = body.offsetWidth;
要查找文档的宽度,请使用:
$(document).width();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.