skip to Main Content

our react application redirecting to third party url(using window.open ) and that third party url is hitting 3-4 other url and once process completed it is redirect to our own url (React app). now from here if user click browser back button it’s again navigating to that previous all third party url that i dont want

to resolve this issue –

  1. i used "replace" from react router, its replacing only current url not all previous url
  2. cann’t use iframe – that third party url not suitable for iframe
  3. window.history.replaceState("","",url)- not working- if i go back still navigating to third party url

2

Answers


  1. First use "window.history.pushState" when your opening a third part url. Then call "window.history.replaceState" this replaces the current history entry with the final successful redirection URL. This ensures that clicking the back button only goes back to the previous state within your React app.

    Login or Signup to reply.
  2. There is nothing you can do about that.

    You cannot control the history state of someone else’s website.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search