Can I stop people from copying my website our source code? The answer is no.
I hear a lot of website owners complaining that their competitors are copying their website content. I have to tell them plain and simply, there's nothing they can do about it. If you have a website that's good enough to copy, people will do just that. It's extremely annoying I know.
You can make it more difficult for these copycats to access your source code. You can disable the right mouse click view source code option. They will still be able to use the browser's menu to view the source code, but why not force them to take a few extra steps for spite?
How to disable View Source
- Open your HTML document in your favorite editing program and enter this code in the header section:
document.onselectstart=new Function ("return false")
- Save your document.
- If you have a WordPress website you can access your header code by logging into admin then clicking on 'Appearance' > 'Editor' > 'Header'. Don't forget to save your changes.
- Don't forget to save your changes.
Again, this doesn't prevent visitors from viewing your source code using the browser's menu options, this only prevents visitors from viewing your webpage source code using the right mouse click view source option.