4

PHPの初心者:)

ブログ プロジェクトで作業しているときに、インデックス ページの [コメント] リンクをクリックして、特定の (完全な) 投稿とそのコメントを含む別のページにユーザーを移動 (送信) したいと考えています。

ユーザーをコメント div に直接送信したいと考えています。しかし、疑問符「?」の後にリンクとともに投稿 ID を提供する必要もあります。#comments div (html セクション) を URL のどこに含めるかを知りたいです。

前もって感謝します。

4

3 に答える 3

7

idまず、ブラウザ(ユーザー)がスクロールしたい要素に を割り当てます。

元。

<div id="mycomment">

次に、追加する URL を生成し、#選択idします。

元。

http://example.com/post/1/#mycomment
于 2013-10-03T11:43:41.253 に答える
4

これを行うには、空の<a>タグを使用できます。

コメントの前にこれを貼り付けます<div>:

<a name="comments"></a>

#comments タグを付けてページに入ってみてください。例: http://mysite.com/example.php?postID=123#comments

于 2013-10-03T11:35:13.710 に答える
1

アンカータグに名前を追加し、<a name='anchor1'>プレフィックス # を使用して href にリンクします<a href='#anchor1'>Comment</a>

<a href="#anchor1">First</a> |
<a href="#anchor2">Second</a> |
<a href="#anchor3">Third</a> |
<a href="#anchor4">Forth</a> |
<a href="#anchor5">Fifth</a> 

<a name='anchor1'>First comment header</a>
<p>First comment content<br>First comment content<br>First comment content<br>First comment content<br>First comment content<br>First comment content<br>First comment content<br>First comment content<br>First comment content<br>First comment content<br>First comment content<br>First comment content<br>First comment content<br>First comment content<br></p>

<a name='anchor2'>Second comment header</a>
<p>Second comment content<br>Second comment content<br>Second comment content<br>Second comment content<br>Second comment content<br>Second comment content<br>Second comment content<br>Second comment content<br>Second comment content<br>Second comment content<br>Second comment content<br>Second comment content<br>Second comment content<br>Second comment content<br></p>

<a name='anchor3'>Third comment header</a>
<p>Third comment content<br>Third comment content<br>Third comment content<br>Third comment content<br>Third comment content<br>Third comment content<br>Third comment content<br>Third comment content<br>Third comment content<br>Third comment content<br>Third comment content<br>Third comment content<br>Third comment content<br>Third comment content<br></p>

<a name='anchor4'>Fourth comment header</a>
<p>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br>Fourth comment content<br></p>

<a name='anchor5'>Fifth comment header</a>
<p>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br>Fifth comment content<br></p>

コメントの詳細が他のページにある場合は、次のように呼び出します

<a href="other_page.php#anchor1">First</a> |
<a href="other_page.php#anchor2">Second</a> |
<a href="other_page.php#anchor3">Third</a> |
<a href="other_page.php#anchor4">Forth</a> |
<a href="other_page.php#anchor5">Fifth</a> 
于 2013-10-03T11:49:09.040 に答える