How can I use Javascript to protect my web pages?
A. Short answer, you can’t. Long Answer: Since visitors to your web site can disable Javascript in their browser, javascript can’t be used as a protection mechanism. Even without disabling Javascript I can easily see the whole code for your web page by simply running another javascript which will undo anything you did to make the page unavailable. Search for “Bookmarklets” in Google for a bunch of simple but useful scripts like that which can be set up as Bookmarks (Favorites for you IE users). Please note that “No Right Click” scripts (one of the favorite uses of javascript to “protect” a web page) are considered at best a “waste of time” but more often as “user antagonistic” by most of the regulars here. You can get answers on how to write them, fix them and the like eventually but you may find yourself running a gauntlet of questions about why you would want to do such a thing before you get assistance. Scripts that make it harder to provide help do not endear you to the volunteers