简体   繁体   English

有没有一种方法可以从地址栏中提取404 URL并自动填充表单字段?

[英]Is there a way to pull a 404 URL from the address bar and autopopulate a form field?

I'm encountering an issue where a user lands on a 404 page and then clicks a button to submit the 404 error they encountered. 我遇到的问题是,用户进入404页面,然后单击按钮提交他们遇到的404错误。 From there, they fill out a jotform (server config preventing simple form implementation from Wordpress or auxiliary plugins.) 从那里,他们填写了一个jotform(服务器配置阻止了Wordpress或辅助插件的简单表单实现。)

The next step we'd like to take is to autopopulate the URL form field with the 404 error URL they encountered. 我们要采取的下一步是使用他们遇到的404错误URL自动填充URL表单字段。 Just some background info, we're operating the site through wordpress on a Windows box. 仅提供一些背景信息,我们通过Windows框上的wordpress操作该网站。

Is this possible? 这可能吗? Seems unlikely, but I thought I'd ask and see what other developers might recommend. 似乎不太可能,但是我想问一下,看看其他开发人员可能会推荐什么。 (I'm aware of webmaster, analytics, and backend tracking of 404s. This was a specific setup requested for direct input from the user.) (我知道网站管理员,分析和404后端跟踪。这是要求用户直接输入的特定设置。)

[First time here, btw. [第一次来,顺便说一句。 Sorry in advance if I've broken any rules.] 抱歉,如果我违反任何规则。]

In most cases, you can access the URL of the currently requested page via a PHP superglobal - $_SERVER["REQUEST_URI"] . 在大多数情况下,您可以通过PHP超全局变量$_SERVER["REQUEST_URI"]访问当前请求页面的URL。

This won't always be available to you, and there may be a Wordpress helper to get it without accessing the superglobal directly - but this should get you started. 这并不总是可用的,并且可能有一个Wordpress帮助程序可以在不直接访问超全局变量的情况下获取它-但这应该可以帮助您入门。

Javascript is another simple option - window.location.href or similar will normally give you whatever is in the address bar. Javascript是另一个简单的选项window.location.href或类似名称通常会为您提供地址栏中的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM