Create URL in Yii with element name with # [closed

2019-06-17 05:19发布

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条回答
SAY GOODBYE
2楼-- · 2019-06-17 05:50

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'));
查看更多
登录 后发表回答