php - 在提交 POST 表单后使用 anchor

标签 php html web-applications

我需要让页面在用户点击发布按钮后加载到页面内的特定标签。

注意:我使用的是 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>

如您所见,我着陆的地方是常规标签文本,而不是超链接。因此,我将 anchor 线作为指示符放在标题之前。

问题:

页面没有到达我放置的位置 (name="here")。页面到达顶部。有没有简单的方法让它降落在(name="here")?

最佳答案

只需将片段包含在表单的 action 属性中,例如

<form method="post" action="po.php?id=44#here">

此外,使用 ID 属性作为片段位置要好得多。丢掉空 anchor 并将段落更改为...

<p id="here">Total number of Posts 55</p>

关于php - 在提交 POST 表单后使用 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8079575/

相关文章:

php - 将数据从 PostgreSQL 数据库移动到新的 MySQL 数据库的最简单方法是什么?

Javascript onchange on select inside 脚本

html - 取消文本不透明度

css - 如何删除遗留网络应用程序中的 CSS 意大利面条?

web-applications - 我可以在 Chrome 中清除网络应用程序吗?

php - 使用php linux服务器解析大文件

javascript - 未捕获的类型错误 : Cannot set property 'innerHTML' of undefined

python - Raspberry Pi Web 应用程序配置向导

php - 在 apache 服务器上使用 PHP 将 ppt/pptx 转换为 JPG/PNG

javascript - 不能多次使用 Web 组件