如何使用Javascript阻止查看页面源? [英] How to prevent View Source of page using Javascript?

查看:78
本文介绍了如何使用Javascript阻止查看页面源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止使用文件>另存为下载页面源代码?

How to prevent to download the source code of page using File > Save as?

推荐答案

你不能。在浏览器中查看页面时,页面实际上已经被下载了。如果您想保护内容,您可能会对源进行模糊处理,并且根据您正在执行的操作,您可能会在页面下载后使页面无法正常运行(即,使页面的某些行为依赖于对服务器的Ajax请求)。但总会有解决方法。

You can't. The page is effectively already being downloaded when you view it in the browser. If you want to protect the contents, you might be able to obfuscate the source, and depending on what you are doing you might be able to make the page non-functional once it has been downloaded (ie making some behavior of the page rely on an Ajax request to your server). But there will always be workarounds.

这篇关于如何使用Javascript阻止查看页面源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆