2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

HtmlHelper::linkでのURLフラグメント(#書き)の指定の仕方

Last updated at Posted at 2014-10-21

'#'=>'フラグメント'という書き方をすればよい。

<?php
echo $this->Html->link(
    "ユーザー詳細",
    array(
        'controller' => 'users',
        'action' => 'detail',
        8,
        '#'=>'top'
    )
);

これで以下のようなリンクが生成される。

<a href="/users/detail/8#top">ユーザー詳細</a>

ところで

#でURLの最後にid要素を入れるのって、一般的になんて呼ばれるんですかね? 「Webを支える技術」には「URLフラグメント」という書き方をされていましたが、あまり聞いたことがなく。このことばはそこそこ使われているのでしょうか。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?