JavaScript City

Screen Resolution on Page

Writes the viewer's screen resolution onto the page.

Script Code

Grab a copy of the file below and place it in the same directory as the Web page on which you will use the script (if you wish to place the script file in a different directory you will need to make the necessary adjustments to the src attribute of the script tag that calls it).

sdetect1.js

The code below should be placed between the <body> and </body> tags where you want the text to appear.

Example

A working sample of the script is shown below.

Options

You can edit the appearance of the text by adding the screen_res ID to your style sheet and adjusting as desired.

You can change the message text itself by editing the line below in the sdetect1.js file. Be careful with the variables on the line.

s_span.innerHTML = "Your screen resolution is "+screen.width+"x"+screen.height+" pixles.";

Accessibility

A server side script, java applet, or plugin may be able to provide the same information as a backup if necessary.


eXTReMe Tracker