How to determine the size of a website?

I want to adjust the size of my html-viewer to the site I am looking at with it. Is there a way to determine the width of a site, so that I can adjust my htmlviewer,width to it? I wonder whether this is possible and how to retrieve it.
Some code could be helpfull :wink:

I don’t actually think HTML Viewer can give you any kind of response you need.

However, with some cleverness you could get the source with a HTTP Socket, scan it for CSS (on the page or externally,) and use any @media queries in the CSS to determine the width you would need.

I’m curious to know why you want to do that? In general, websites resize to fit the viewer, not the other way around.

document.documentElement.offsetWidth

I’m pretty sure that returns the width of the document which is always the same width as the viewer.

OffsetWidth returns the amount of space an element needs to draw its contents, but getting it from the document will almost always return the width of the browser, unless the browser is too small.

A word of caution: OffsetWidth measures differently on different platforms. It’s also here costly in terms of CPU because it requires the whole page to be recalculated. Use it sparingly.

Better to resize the website to the viewport (responsive) instead of the viewport to the website (hack)