Best Viewed At
browser tricks 1997 still worksReads the visitor's screen size and tells them off if it is not 800x600.
In 2026: Works, but screen.width was always the whole display, never the browser window, and on a HiDPI screen it now reports CSS pixels rather than hardware pixels. Use window.innerWidth if you want the size of the actual viewport.
Where it came from: Netscape JavaScript 1.2 screen object, 1997. MDN ↗
<script language="JavaScript">
document.write("Your screen is " + screen.width + "x" + screen.height
+ " at " + screen.colorDepth + " bit colour.<br>");
if (screen.width < 800) {
document.write("<b>This site is best viewed at 800x600 or higher!</b>");
}
</script>
<!-- The size that actually matters is the window, not the screen -->
<script>
document.write("Your browser window is "
+ window.innerWidth + "x" + window.innerHeight);
</script>