简体   繁体   中英

Using hidden frame to store or pass data between pages

We need to implement a mechanism to persist information between web pages in the same session. There is a lot of information on the client-side and passing it back and forth to the server across requests is something we want to avoid. HTML5 local storage is one option.

The other option mentioned was "using a hidden frame where the data is kept". I am not sure what this option really means.

  • Does it mean keeping a hidden frame that holds on to the data across page requests?
  • How would this be accomplished? Are there any jquery plugins or sample code I can look at?
  • What are the advantages and disadvantages?

I am not aware of a way where you can keep data in the main page and use a hidden iframe / frame to persist data. This is because once the main page is reloaded (when you go to another page), everything in the iframe is lost.

You would basically use the main page as your data-storage location. On top of the main page, you would superimpose an iframe . The user would interact with your site through the iframe . From the user's perspective, there is no difference. You can persist information by writing to the parent frame (the main page). Since the main page is never getting reloaded, you can persist data inside it.

I am not aware of any Javascript libraries that do this; I will take a look though.

Keep in mind that this might affect SEO and possibly navigation (not back/forward buttons). Another point, as Guffa noted, is that users cannot share links to your page since the URL in the address bar never changes (all interaction is via the iframe ). So when your user sends someone a link, they will end up at the very first page.

You can't keep a frame from one page to another, so the only way to use that is to make the frame cover the window and load the actual pages in the frame. That way you can keep the data in the surrounding page that won't be replaced.

This of course means that you actually never leave the page. The URL in the location bar remains the same when the content changes, so you can't bookmark a specific page or share it with others. Search engines will link to the content pages instead of the frame, so anyone finding your page that way will end up on a non-functioning frame page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM