JAVASCRIPT - HOW TO View Web Page as Text Only - Javascript Source Code

JAVASCRIPT - HOW TO View Any Web Page Text Only by Stripping All the HTML Tags from the Web Page. 2 Lines of Javascript Code to View Web Page as Text Only

Home Short:

To view a web page as text only is a simple matter of stripping all the html tags from the web page. This essentially removes the glue that holds the web page together and formats its appearance so after executing this Javascript code you are left with text only on the web page.

Try Viewing this Web Page as Text Only

Click the View Web Page as Text Only button to strip all the html tags from this web page and view a text only version of this web page.

After clicking the above button, press the F5 key on your keyboard to refresh this page and view it normally again.

One thing you might notice is although the web page is text only, the css style code text still shows and this is somewhat distracting and not 100% what we are looking for.

To remove all the code between style tags we want to add the code .replace(/<style([\S\s]*?)>([\S\s]*?)<\/style>/g, '')

Try Viewing this Web Page as Text Only with CSS Code Removed

Click the View Web Page as Text Only, Style Code Removed button to strip all the html tags from this web page, strip all style tags, and view a text only version of this web page.

After clicking the above button, press the F5 key on your keyboard to refresh this page and view it normally again.

The one last distracting remaining is we can still see the Javascript code. To remove all the Javascript code we have to insert one more section of replace code .replace(/<script([\S\s]*?)>([\S\s]*?)<\/script>/g, '')

Try Viewing this Web Page as Text Only with CSS Code Removed and Javascript Code Removed

Click the View Web Page as Text Only, Style Code Removed, Javascript Code Removed button to strip all the html tags from this web page, strip all style tags, and strip all the Javascript code and view a text only version of this web page.

After clicking the above button, press the F5 key on your keyboard to refresh this page and view it normally again.

Now the code to view a web page as text only is complete.

S
H
A
R
E