如何将javascript变量/对象从一个页面传递到另一个页面?

编程入门 行业动态 更新时间:2024-10-23 11:28:05
本文介绍了如何将javascript变量/对象从一个页面传递到另一个页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将JavaScript对象/变量从页面传递到另一个页面。所以我可以使用数据的一些领域,我希望这个值是隐藏的,而不是可见的,而我的价值从一个页面到另一个我已经看到许多通过http参数传递的例子,我不希望并且会话变量在服务器端管理,因此无需在服务器端对该页面进行管理。

我想将值作为隐藏字段或值传递给下一个页。如何通过

window.location =website / nextpage.jsp打开新页面时将其传递到新页面。

另外一个说明,我是初学者,所以如果这个问题似乎含糊不清,请抱歉。

解决方案

假设您不想使用会话变量,Cookie或本地存储: 您不能隐藏一个参数,以便您的网站用户无法看到它。

如果您通过POST请求提交数据 - 您可以使用隐藏的表单元素。

< form method =post> < input type =hiddenname =statevalue ={YOUR PARAMETER}/>

如果您使用window.location - 您必须使用GET请求来完成它

window.location =website / nextpage.jsp / param / {YOUR PARAMETER};

I want to pass javascript object/ variable from page to another. so that i can use data for some fields, i want this values to be hidden and not visible while i my passing value from one page to another I have already seen many examples of pass via http parameters, i dont want that and also session variables manage on server side, cause nothing has to be manage on sever side for that page.

i want to pass value as a hidden field or value to next page. how to pass it to new page when i open new page via

window.location="website/nextpage.jsp";

Also a note, i am beginner, so please sorry if the question seems to vague.

解决方案

Assuming you do not want to use session variables, cookies or local storage:

You can not "hide" a parameter so that your website user will not be able to see it.

If you submit data via a POST request - you can use hidden form elements.

<form method="post"> <input type="hidden" name="state" value="{YOUR PARAMETER}" />

If you use window.location - you will have to do it with a GET request

window.location="website/nextpage.jsp/param/{YOUR PARAMETER}";

更多推荐

如何将javascript变量/对象从一个页面传递到另一个页面?

本文发布于:2023-05-25 10:55:22,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:词库加载错误:Could not find file &#039;D:\淘小白 高铁采集器win10\Configuration\Dict_Sto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!