JavaScript City

View Page Source Button

This script allows the viewer to view the source code of the current page by clicking a button.

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).

sdetect8.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 change the button text by editing the value attribute of the input tag in your HTML document (change the bold (strong) text below):

<input type="submit" value="View Source!" />

Accessibility

A message telling viewers how to do the same thing via the browser should suffice.


eXTReMe Tracker