I was looking at a nice site today and when I tried to see their 'source code' or 'page source', nothing happened. So, how do you block someone from seeing your meta tags and such?

Is there a downside to doing this sort of thing?

Dani AI

Generated

As noticed, some sites try to make "View Source" feel like it does nothing. That is usually done with client-side tricks to block right-clicks or keyboard shortcuts. and pointed toward those tactics, and correctly noted that code executed on the server never appears in the delivered HTML. Below are practical, accurate notes you can apply now and guidance on safer alternatives.

To see the HTML a server actually returns (bypassing client-side blocks), fetch the page directly or inspect the network traffic. Example using a command-line HTTP client:

curl -sL 'https://example.com/' | sed -n '1,200p'

That returns the server response (first 200 lines shown). Browser DevTools Network -> Document or the saved page (.html) will also show what was sent. If content is injected later by XHR/fetch, check the Network tab for those requests.

Security and SEO notes: never place secrets (API keys, credentials) in client-side HTML or JavaScript; keep them on the server with proper access control. Attempts to "hide" meta tags or content from users can harm search visibility and provide a false sense of protection — see Google Search Central on JavaScript and indexing for how crawlers handle client-side content (https://developers.google.com/search/docs/crawling-indexing/javascript). For sensitive-data guidance, refer to OWASP best practices (https://owasp.org/www-project-top-ten/).

If the goal is to deter casual copying, use non-technical measures (watermarks, licensing, rate limits, authenticated access, DMCA procedures) and server-side controls for paywalled content. Client-side blocking only inconveniences ordinary users and does not stop a determined retriever.

Recommended Answers

All 4 Replies

I'm not sure if there is a code like that at w3schools.com but I think it's a javascript code that would hide the entire code of the page.

Disable java script and try viewing source.

Ive done a research on the web and it says that it is used it to keep people from stealing your content. They will probably have copy and paste disabled too. Theres still ways of seeing it. but i dont know how they do it

Ultimately there is nothing you can do to hide any source code that is served to the browser. Any attempts to hide that can be bypassed by simply using an HTTP viewer or other tool that reads directly from the webserver bypassing a browser (e.g., the HTTP viewer at http://www.rexswain.com/httpview.html).
This would include any source code in included javascript or css files.

You can try to obfuscate your code. For example, there are compression utilities for JavaScript that make it almost unreadable (look at Google's Javascript and you will see this). Still, a smart engineer could figure it out.

Note that code that is executed on the server, such as PHP, ASP, .NET, JSP, etc are NOT readable, as long as your server is configured to execute those files rather than return the source. Of course, if your server is not configured correctly, then a hacker might get into these. That is a whole other area -- making sure your server is safe from hackers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.