如何从视图代码/检查元素浏览器中隐藏表单代码? [英] How to hide form code from view code/inspect element browser?

查看:25
本文介绍了如何从视图代码/检查元素浏览器中隐藏表单代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从视图代码/检查元素浏览器中隐藏表单代码,我该怎么做?

这是我的代码,请看下面:

<div style=" text-align: center; padding: 300px; font-family: lato; ">请稍候重定向页面......<br><img src="http://maps.nrel.gov/sites/all/modules/custom_modules/hydra/assets/images/loading_bar.gif" border="0">

<form name="f1" action="payments.php" method="post"><input type="hidden" name="id_crad" value="..."><input type="hidden" name="currency_code" value="USD"><input type="hidden" name="amount" value="12.99"></表单><script type="text/javascript">setTimeout(function(){f1.submit();}, 3000);

请看图

解决方案

你根本做不到.

代码检查器专为调试 HTML 和 JavaScript 而设计.它们通过显示网页的实时 DOM 对象来实现.这意味着它会显示您在页面上看到的所有内容的 HTML 代码,即使它们是由 JavaScript 生成的.一些检查员甚至会在 Iframe 中展示代码.

一些禁用键盘/鼠标交互的 JavaScript 怎么样...

有一些 JavaScript 技巧可以禁用页面上的某些键盘、鼠标交互.但是总是可以解决这些技巧.例如,您可以毫无问题地使用浏览器顶部菜单启用 DOM 检查器.

试试论文:

它们不受 JavaScript 的控制.

大图

考虑一下:

  1. 网页上的所有内容都由浏览器呈现,因此它们的抽象级别低于您的 JavaScript.他们守卫着所有的门,拿着所有的钥匙".
  2. 浏览器希望网站在它们上正常运行,否则它们的用户会鄙视它们.
  3. 因此,浏览器希望使用代码检查器等工具将一切的较低级别的标记公开给网络开发人员.

基本上,浏览器是您的 JavaScript 之神.他们希望通过代码检查员授予 Web 开发人员超能力.即使您的技巧在一段时间内有效,浏览器也希望在将来撤消它.

你在与上帝开战,你注定要失败.

结论

简单来说,如果您不希望人们在他们的浏览器中获得某些内容,您首先应该永远不要将其发送到他们的浏览器.

I want to hide form code from view code/inspect element browser , how can i do that ?

This is my code, please see below:

<div style=" text-align: center;  padding: 300px; font-family: lato; ">
     Please wait redirect page ......<br>
    <img src="http://maps.nrel.gov/sites/all/modules/custom_modules/hydra/assets/images/loading_bar.gif" border="0">
</div>


<form name="f1" action="payments.php" method="post">
<input type="hidden" name="id_crad" value="...">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="12.99">
</form>


<script type="text/javascript">
setTimeout(function(){f1.submit();}, 3000);
</script>

Please see picture

解决方案

You simply can't.

Code inspectors are designed for debugging HTML and JavaScript. They do so by showing the live DOM object of the web page. That means it reveals HTML code of everything you see on the page, even if they're generated by JavaScript. Some inspectors even shows the code inside Iframes.

How about some JavaScript to disable keyboard / mouse interaction...

There are some JavaScript tricks to disable some keyboard, mouse interaction on the page. But there always are work around to those tricks. For instance, you can use the browser top menu to enable DOM inspector without a problem.

Try theses:

They are outside the control of JavaScript.

Big Picture

Think about this:

  1. Everything on a web page is rendered by the browser, so they are of a lower abstraction level than your JavaScript. They are "guarding all the doors and holding all the keys".
  2. Browsers want web sites to properly work on them or their users would despise them.
  3. As a result, browsers want to expose the lower level ticks of everything to the web developers with tools like code inspectors.

Basically, browsers are god to your JavaScript. And they want to grant the web developer super power with code inspectors. Even if your trick works for a while, the browsers would want to undo it in the future.

You're waging war against god and you're doomed to fail.

Conclusion

To put it simple, if you do not want people to get something in their browser, you should never send it to their browser in the first place.

这篇关于如何从视图代码/检查元素浏览器中隐藏表单代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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