提交POST表单后使用锚点 [英] Use Anchor after POST Form Submission
问题描述
在用户单击发布"按钮后,我需要让页面加载到页面中的特定标签上.
注意:我正在使用PHP
Note: i'm using PHP
表单代码示例:
<form action="po.php?id=44" method="POST">
<input type="hidden" name="here" value="#here" />
<input name="btn_send" type="submit" value="Post" />
</form>
页面应降落在页面中某个位置,该页面之间应有一个 标题,如下所示
代码示例:
<a name="here"></a>
<p>Total Number of Posts 55</p>
如您所见,我登陆的地方是常规标签文本,而不是超链接.因此,我将锚线作为指标放在标题的前面.
As you see, the place i land is a regular label text, not hyperlink. Therefore, i put the anchor line as an indicator just before the title.
问题:
页面不在我放置的位置(名称=此处").该页面到达顶部.有没有简便的方法可以使它到达(name ="here")?
Page doesn't land where i put (name="here"). The page lands to the top. Is there easy way to make it land at ( name="here")?
推荐答案
仅将片段包含在表单的action
属性中,例如
Simply include the fragment in your form's action
attribute, eg
<form method="post" action="po.php?id=44#here">
此外,使用ID属性作为片段位置要好得多.失去空的锚点,然后将段落更改为...
Also, using ID attributes as fragment locations is much nicer. Lose the empty anchor and change your paragraph to...
<p id="here">Total number of Posts 55</p>
这篇关于提交POST表单后使用锚点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!