在 Yii 中使用元素名称创建 URL # [英] Create URL in Yii with element name with #

查看:36
本文介绍了在 Yii 中使用元素名称创建 URL #的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 Yii 中创建 URL,并在页面上指定一个 div 以在单击时聚焦...我知道我需要将带有 # 的 div 名称放在 URL 中,但是我该怎么做在 Yii 的 createUrl 函数中指定...

I need to create URLs in Yii with specifying a div on the page to focus when clicked... I know I need to put the div name with # in the URL, but how do I specify that in createUrl function of Yii...

createUrl() 函数仅提供参数选项,而不提供元素选项......据我所知.

The createUrl() function only provides options for parameters, not for elements...as per my knowledge.

推荐答案

如果检查 createUrl:

其他 GET 参数(名称=> 值).名称和值都将进行 URL 编码.如果名称为#",则相应的值将被视为锚点并附加到 URL 的末尾.

additional GET parameters (name=>value). Both the name and value will be URL-encoded. If the name is '#', the corresponding value will be treated as an anchor and will be appended at the end of the URL.

你可以这样添加:

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

这篇关于在 Yii 中使用元素名称创建 URL #的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆