How to ensure history back is not redirected to the same original page again when external site has a redirection page?

تبليغ
سؤال

يرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.

تبليغ
‎إلغاء

Let’s say an external site has a redirection page before actually moving to the internal site.
This internal site only has a button that will let you go back using history.back().

What’s happening here is that we now have a “loop” that redirects to the external redirection page using history.back(), and then the user will be redirected once again to the internal site.

Flow:

External site -> user clicks on internal site link -> external site sends user to external redirection page -> user redirects to visit the internal site -> user click history.back button -> user get redirected to external redirection page -> user redirects to visit the internal site again

I thought about saving page visit in localstorage, so that if it gets redirected back to the internal site again it will instead do history.go(-2).
I am also aware of https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer document.referrer, but that will also degrade the UX since the user gets redirected back and forth at least once.

The only solution I could think of is having a query parameter upon visiting the internal site someurl.com/?redirects=2, so that we could do history.go(-redirects). However, that requires the external site to decide how many redirects it has.

Is it possible to know if user comes from a redirection page from the external site?

0
X 5 أشهر 2022-07-10T12:01:22+03:00 0 إجابة 1 مشاهدات مبتدئ 0

‫أضف إجابة

تصفح
تصفح

مجهول يجيب