Answer the question
In order to leave comments, you need to log in
Yii2 how to redirect to referrer with anchor?
Hello.
The problem is the following, there is a page with the order of the goods, where it is placed in the basket.
That is, first the action of adding a product to the cart is performed, and then a redirect to the previous page, but with an anchor to the list of products, so as not to scroll down again.
return $this->redirect([yii::$app->request->referrer,'#' => 'grid']);
Answer the question
In order to leave comments, you need to log in
I tried several ways, but so far I had to do this -
$this->registerJs('window.onload = function() {
location.hash = \'#grid\';
}');
Good evening.
<?php
// создает якорный URL: /index.php?r=post/view&id=100#content
echo Url::to(['post/view', 'id' => 100, '#' => 'content']);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question