N
N
Nick Tit2015-12-20 16:11:18
JavaScript
Nick Tit, 2015-12-20 16:11:18

Yii2 How to implement a redirect to the same page and to the RIGHT place of the user?

I return the user to the same page
like this

return $this->redirect(Yii::$app->request->referrer);


But one caveat! It always flips to the top of the page,
and not to the place where the user was on the page.

How to implement a transfer to the same page and to the RIGHT place of the user (to the same product or to the same article or paragraph that the user read before the redirect) ?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
J
jacksparrow, 2015-12-20
@jacksparrow

Moving to an element is easily done through js

H
HeBonpoc, 2015-12-20
@HeBonpoc

Without JS, this will not work, because for the browser it is not similar to the "back" button, but a full-fledged new page. That is, you have to somehow remember and transmit the user's location. It will be easier to make your call ajax so that the page does not reload at all.

N
Nikita, 2015-12-21
@bitver

In the URI string, pass #element_id at the end, provided that there is, for example, a div with id = "element_id" will transfer you to it.

R
Rafis Bagautdinov, 2015-12-28
@bagau

If you send the position of the top of the page from the top of the document before the update, then you can pass this value to get and rewind the page using javascript to this value

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question