开发者

When main page is refreshed (with F5) inner iframe location is missing

开发者 https://www.devze.com 2023-04-12 06:47 出处:网络
I set a src attribute of an iframe as a home page, so after login we redirect the user to the home page.

I set a src attribute of an iframe as a home page, so after login we redirect the user to the home page.

When the user navigates around it is fine, but the problem comes when the user uses the F5 key on the keyboard as a refresh button.

It refreshes the entire page, which kicks them back to the main page (home page which was set as the src in iframe).

So, I have put the last visited page url in a session variable. But a problem occurs when the last visited page url uses the post method. Then just put开发者_开发知识库ting the url in the iframe src does not work as the form has method=post.


this is a common post problem, not related to iframe actually. this is the method i use to prevent this issue:

  • use posted data (store it to database etc.) and immediately redirect to another page before showing anything on screen. if some data needs to be used on the next page, read it from stored place or use either session or get method to pass to the next page.

that way, you won't have any problems with refreshing the page. you can also store the next page's url to the session variable at the posted page.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号