-2

我想做一些简单的结果分页,但我没有客户端开发经验。
所以我检查了现有网站是如何通过:View Sourceof IE.
youtube我看到以下内容:
它每页显示 20 个结果并提供 7 个页面的链接。
来源如下:

<a href="/results?search_query=html+pagination&amp;page=1" class="yt-uix-button  yt-uix-pager-button yt-uix-button-toggled yt-uix-sessionlink yt-uix-button-default" data-sessionlink="ei=73WLUfrBCsaZ8gOtjoDYAw" data-page="1" <span class="yt-uix-button-content">1</span></a>   

<a href="/results?search_query=html+pagination&amp;page=2" class="yt-uix-button  yt-uix-pager-button yt-uix-sessionlink yt-uix-button-default" data-sessionlink="ei=73WLUfrBCsaZ8gOtjoDYAw" data-page="2" <span class="yt-uix-button-content">2</span></a>  

<a href="/results?search_query=html+pagination&amp;page=3" class="yt-uix-button  yt-uix-pager-button yt-uix-sessionlink yt-uix-button-default" data-sessionlink="ei=73WLUfrBCsaZ8gOtjoDYAw" data-page="3" <span class="yt-uix-button-content">3</span></a> 

<a href="/results?search_query=html+pagination&amp;page=4" class="yt-uix-button  yt-uix-pager-button yt-uix-sessionlink yt-uix-button-default" data-sessionlink="ei=73WLUfrBCsaZ8gOtjoDYAw" data-page="4" <span class="yt-uix-button-content">4</span></a>  

<a href="/results?search_query=html+pagination&amp;page=5" class="yt-uix-button  yt-uix-pager-button yt-uix-sessionlink yt-uix-button-default" data-sessionlink="ei=73WLUfrBCsaZ8gOtjoDYAw" data-page="5" <span class="yt-uix-button-content">5</span></a>  

<a href="/results?search_query=html+pagination&amp;page=6" class="yt-uix-button  yt-uix-pager-button yt-uix-sessionlink yt-uix-button-default" data-sessionlink="ei=73WLUfrBCsaZ8gOtjoDYAw" data-page="6" <span class="yt-uix-button-content">6</span></a> 

<a href="/results?search_query=html+pagination&amp;page=7" class="yt-uix-button  yt-uix-pager-button yt-uix-sessionlink yt-uix-button-default" data-sessionlink="ei=73WLUfrBCsaZ8gOtjoDYAw" data-page="7" <span class="yt-uix-button-content">7</span></a>  

<a href="/results?search_query=html+pagination&amp;page=2" class="yt-uix-button  yt-uix-pager-button yt-uix-sessionlink yt-uix-button-default" data-sessionlink="ei=73WLUfrBCsaZ8gOtjoDYAw" data-page="2"><span class="yt-uix-button-content">Next »</span></a>

所以我假设这sessionlink就像一个会话标识符?
我怎么能在我的服务器端代码中使用它?
又何必Next/results?search_query=html+pagination&amp;page=2

4

1 回答 1

0

这仍然可以通过这种方式简化:

<a href="paged?page=1">« Prev</a>
<a href="paged?page=1">1</a>
<a href="paged?page=2">2</a>
<a href="paged?page=3">3</a>
<a href="paged?page=3">Next »</a>

仅对于纯分页部分,您无需担心会话标识符。有一个GET名为的变量page将页码传递给paged页面。

于 2013-05-09T11:05:00.673 回答