页面重定向到页面上的指定位置 [英] page redirect to specified location on the page

查看:79
本文介绍了页面重定向到页面上的指定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从一个链接重定向到页面上指定行或指定点上的另一页面.
例如,我有一个页面,其中包含对topic1到topic5的描述
我还有另一个页面,其中包含从topic1到topic5的超链接
现在,如果用户单击超链接topic4,则必须将他重定向到描述页面,但必须在该页面上显示topic4的位置.
(在C#中)

希望你能理解我的问题.
在此先感谢

how can i redirect from one link to another page at the specified line or point on the page.
eg i have a page containing description of topic1 to topic5
i have another page containing hyperlinks topic1 to topic5
now if user clicks on the hyperlink topic4 than he must be redirect to the description page but at the location where topic4 is displayed on that page.
(in c#)

hope u can understand my problem.
thanks in advance

推荐答案

这有一个很好的解决方案(我做到了).将内容放在要将数据重定向到的div内.每个div必须具有唯一的ID,例如,如果您有5个不同的主题,则可以将div ID作为
divTopic1
divTopic2
divTopic3
divTopic4
divTopic5

现在,在超链接上,您可以将重定向设置为

< a href ="http://www.xyz.com/topics/#topic1"> topic1</a>
< a href ="http://www.xyz.com/topics/#topic2"> topic2</a>
< a href ="http://www.xyz.com/topics/#topic3"> topic3</a>
< a href ="http://www.xyz.com/topics/#topic4"> topic4</a>
< a href ="http://www.xyz.com/topics/#topic5"> topic5</a>

对于动态主题(如果它们来自数据库)也可以通过生成div和超链接的相应ID来完成.

希望这能解决您的问题.

Anurag
This has a very good solution(which I did). Place the contents inside a div to which you want to redirect the data. Each div must have a unique id, for example if you have 5 different topics then you can have div ids as
divTopic1
divTopic2
divTopic3
divTopic4
divTopic5

now, on the hyperlink, you can make the redirection as

<a href="http://www.xyz.com/topics/#topic1">topic1</a>
<a href="http://www.xyz.com/topics/#topic2">topic2</a>
<a href="http://www.xyz.com/topics/#topic3">topic3</a>
<a href="http://www.xyz.com/topics/#topic4">topic4</a>
<a href="http://www.xyz.com/topics/#topic5">topic5</a>

This could be done for dynamic topics also( if they are coming from a database) by generating corresponding ids of the div and hyperlinks.

Hope this would solve your problem.

Anurag


是的,您必须使用锚定,
给出要跳转到名称的位置,即
yeah u gotta use Anchoring,
give the place you wanna jump to a Name, i.e.
<a name="patel">jump here <a/>and then give the link you want to hit to get to that location the <pre><a href="#patel"> this will jump to ''patel'' link on this page br mode="hold" />
hope that helps.

moreinfo:
<a href="http://www.hypergurl.com/anchors.html">http://www.hypergurl.com/anchors.html</a>[<a href="http://www.hypergurl.com/anchors.html" target="_blank" title="New Window">^</a>]

sry bout the dodgy layout, i never used this ''code block'' thing before..:~


您不需要C#或ASP.NET,只需使用HTML即可.您可以将 name 属性用于< a> 标签.

HTML锚名称属性 [
There is no need for C# or either ASP.NET for your requirement, you just can do that using HTML. You can use name property for <a> tag.

HTML Anchor name Attribute[^]

Also demo page there for your clarification.


这篇关于页面重定向到页面上的指定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆