隐藏页面源中的值,但显示在页面上 [英] Hide values from page source but show on page

查看:79
本文介绍了隐藏页面源中的值,但显示在页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在页面上显示一些值,但将其隐藏在页面源中。林肯定这是不可能的,但我想我会问。



编辑



我正在写我的自己的验证系统,以防止黑客/垃圾邮件发送者。 Im在传递数据时使用加密,但原始值可以在页面源中查看(因此有人可以在源代码上编写循环并提取数据)。

解决方案

官方根据您的标签不包括javascript:否...

但是,可以在加载后写入DOM但可能不会达到你想要的结果。



你可以这样做:

 < div id =something> 

< / div>

然后在页面加载时,在脚注中使用javascript注入该div的值:

 < script type =text / javascript> 
document.getElementById(something)。innerHTML =这是一个以前隐藏的值;
< / script>

这会在加载后将其写入dom,而不是将其写入页源。真正的问题是你究竟在做什么?如果你想完全隐藏某些东西,那么这几乎是一个不便之处。任何想要钻取它的人都可以追踪到这一点。



如果您用真实的意图更新您的问题,那么也许我们可以提供更好的解决方案。



编辑



根据您的编辑,您希望验证系统不显示原始值。
一种选择是将值存储在数据库中,并且只将行的引用id传递给表单,假设这就是您的意思。您可以在服务器端进行所有处理,并将传递给客户端的敏感数据量降至最低。


I would like to be able to show some values on the page but hide them in the page source. Im pretty sure this is not possible, but i figured i would ask.

Edit

I am writing my own verification system to prevent hackers/spammers. Im using encryption when passing the data, but the original value can be currently viewed in the page source ( thus someone can write a loop on the source and pull the data ).

解决方案

Officially as per your tags not including javascript: No...

However, it's possible to write to the DOM after load but probably not going to achieve what you want in the end.

You can do something like this:

<div id="something">

</div>

Then on page load use javascript in your footer to inject the value of that div:

<script type="text/javascript">
    document.getElementById("something").innerHTML = "This is a previously hidden value";
</script>

This will write it to the dom after load and not write it to the page source. The real question is what are you actually trying to do? If you want to totally hide something then this is pretty much just an inconvenience. Anyone wanting to drill it out will be able to track this down.

If you update your question with your real intentions then maybe we can offer a better solution.

EDIT

As per your edit that you want a validation system that does not display the original values. One option is to store the values in a database and only pass the reference id of the row to the form, assuming that's what you mean. You can do all your processing on the server side and minimize the amount of sensitive data passed to the client side.

这篇关于隐藏页面源中的值,但显示在页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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