I want to get the previous page information and reflect it.

Asked 1 years ago, Updated 1 years ago, 41 views

I want to change what appears on hoge.com/hoge by retrieving information from the previous page or dynamically using some method.

Example
hoge.com/hoge/1
hoge.com/hoge/2
hoge.com/hoge/3
hoge.com/hoge/4

Visit ↓

hoge.com/hoge

↓Change

Obtain and view the contents of hoge.com/hoge from the previous page.

javascript php html html5

2022-09-30 12:09

2 Answers

I think the HTTP Header contains the URL of the previous page as the Referer.(Some sites are taking action such as leaving the Referer blank for security reasons, but if it's your site, you should be able to use Header containing the Referer information.)

When you visit hoge.com/hoge, I think it is possible to collect the Referer information (the URL of the previous page) from the HTML Header, and then access it to reflect the information collected on the page.

It's going to be a little complicated because the server needs to detect and deal with certain URLs.

==
I don't know the specific functions required, so this is a very rough answer, but I think the information in the Referer is easy to use.


2022-09-30 12:09

There are many ways.

  • Set cookies on the pre-transition page and read cookies on the post-transition page to change content
  • Same, using localStorage instead of cookies
  • Same, using sessionStorage instead of cookies
  • Same, using Indexed Database instead of cookies
  • When you go from the pre-transition page to the post-transition page, add a query parameter to the URL and read location.search on the post-transition page to change the content
  • Changes the contents of the generated page according to the value in the HTTP Refer header
  • <li> A page transition is performed by POSTing a form with data attached from a page before transition.The server changes the content of the page it generates according to the data that is POSTed.


2022-09-30 12:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.