It seems as if this would be impossible, but does anyone know if there is a way one can prevent visitors from viewing the source of a page?
Yes. Keep it saved on a floppy disk, locked in your own safe. And nowhere else.
It is not possible in any way, shape or form to prevent people from viewing the source code. Their computer has to download it in order to show the page, and once it's done that, there is nothing you can do that will stop them from viewing the source code if that's what they want to do.
I heard rumours it is possible, if you pull the plug on your hosting server.
But with today's Google's cached pages, you can never know.
hide it in plain site (sight, site, get it...?)
code your page so smart no one will ever be able to understand it (on a second thought, others have tried the dumb coding road pretty successful)
make a request to W3C and/or WHATWG to also allow mark up be written in cuneiform (WHATWG may seem more inclined to approve this)
I feel ashamed and stupid for posting the above suggestions, but the question kind of asked it. My apologies team1504. Please look at it like it's a circumstantial joke, as it is.
This question has been asked before, over and over. What is it with people first suckling up FREE knowledge from others (and their web pages) like a sponge and then trying to conceal what they've learned rather than passing it further on?
Think of this: Microsoft, Apple, Adobe and all the software producers CAN'T find a way to stop their products from being pirated. Do you believe you have something similar in size, complexity, software intelligence, that will make it worth you hiding some html mark up?
The typical answer is digging a hole in the garden to bury it... but if you allow the page to be viewable by the public they'll be able to access you markup.
There are ways to slow people that only have a little or basic web knowledge but if it's just static markup in plain sight on a site forget trying to hide it as it won't work.
Whatever you do to try to "protect" your page will lose you a lot of legitimate visitors AND make it more likely that those you are trying to block will actually bypass your block just because they think it is somehow clever that they know how.