html - How to pass javascript variableobject from one page to another? - Stack Overflow

I want to pass javascript object variable from page to another. so that i can use data for some fields

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.

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.

Share Improve this question asked May 22, 2012 at 10:04 Rakesh GargRakesh Garg 272 silver badges5 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 2

You can:

  • Use hashes in the url by reading the window.location.hash. Similar to GET requests, but does not need the server for passing. However, the parameters are visible in the url.

  • Using cookies. Have JS "plant" the cookies on the previous page and read them on the receiving page.

  • You could use DOM storage as well. Similar routine as cookies, plant and read.

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}";

I don't know about JSP specifically, but using a form with POST method hides data from (standard) users.

why dont you use html5's localStorage and sessionStorage for the purpose. for more help visit here

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745195231a4616055.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信