Create URL in Yii with element name with # [closed]

非 Y 不嫁゛ 提交于 2019-12-23 08:57:09

问题


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...

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


回答1:


If you check createUrl:

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.

You can add it like this:

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


来源:https://stackoverflow.com/questions/10085025/create-url-in-yii-with-element-name-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!