[英]how to get source of html, css and javascript and specific portion of webpage
[英]javascript - how to get the inner html width of the webpage
我有幾個客戶端站點的居中寬度大約為900px-1000px,如何使用javascript找出文檔的實際寬度是多少? 我不需要知道窗口的寬度,只需知道實際html文檔使用的寬度即可。
我也無法使用任何div ID來查找它。 我知道我可以為此使用jquery,但是我想使用普通的javascript,因為jquery並非在所有站點上都運行。
在jquery中,我可以使用以下方法找到答案:
$('body').outerWidth(true)
有人可以幫忙嗎?
var body = document.getElementsByTag("body")[0];
var width = body.style.width;
另外一個選項:
var body = document.getElementsByTag("body")[0];
var width = body.offsetWidth;
要查找文檔的寬度,請使用:
$(document).width();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.