html - 如何使用 render() Yii 将 anchor 发送到 URL

标签 html yii anchor

关闭。这个问题需要details or clarity .它目前不接受答案。












想改善这个问题吗?通过 editing this post 添加详细信息并澄清问题.

7年前关闭。




Improve this question




嗨,我不会渲染带有 anchor 位置的 View - http://example.com/index.php#top

可能是这样的:

$this->render('index', ['data' => $data], 'anchor'=>'top');

有任何想法吗?

最佳答案

当您拨打 render网址已设置,因为您在 controller (或 view )。所以此时你不能在url中添加 anchor 。

您必须在调用 Controller 之前设置 anchor 。为此,您可以在创建 url 时设置一个 anchor :

$this->createUrl('controller/action', array('#' => 'the-anchor'));

您也可以使用 redirect将访问者重定向到带有 anchor 的页面
$this->redirect(array('controller/action', array('#' => 'the-anchor')));

但我认为在创建 url 时设置 anchor 是实现您想要的最佳方式。

关于html - 如何使用 render() Yii 将 anchor 发送到 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23336330/

相关文章:

php - 使用 Yii 框架创建反向链接?

javascript - 自动刷新 Controller 和 View Yii

css - 带有 id 和 css 的标签

javascript - 在一个div中定位3个div

html - 如何居中 Bootstrap 导航栏,但也拉 1 个元素吗?

javascript - 仅在页面加载后调用 JavaScript 中的函数

php - Yii 如何高亮显示当前菜单项

CodeIgniter 表类 : Add a Link From a Generated Cell

jquery - 使用 AJAX 然后点击链接

javascript - 将全 Angular slider 缩放到浏览器底部