创建一个自动填充目标页面上的字段的链接 [英] Create a link that automatically fills a field on the target page

查看:105
本文介绍了创建一个自动填充目标页面上的字段的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一份通讯,那位要求我这样做的人想要一个链接......所有完美的没有问题...

现在问题是,当你点击这个链接时,它会出现在一个带有字段的页面上,这个家伙问我是否可以自动填写一个字段。



页面是一些服务的订阅页面,这个人希望我在用他的电子邮件登陆页面时自动填写推荐领域。是否有可能?



谢谢你的解决方案


解决方案这是将字段名称和值放在查询字符串中。 查询字符串是包含字段/值对的URL的一部分。它通过,然后是由& 字符分隔的字段=值对分隔页面地址。例如,

  http://www.example.com 

...会变成...

  http:/ /www.example.com?fieldName=fieldValue 

为了达到这个目的,页面必须解析该字段作为HTTP GET 请求的一部分,然后将该值作为预填充字段返回。如果表单在服务器端正确验证,那么它通常具有解析字段并在同一表单的多个提交中保留其值的功能。这是因为如果某些字段为空或者值无效,那么这样做可以使页面重新绘制错误消息。



这很容易测试 - 只需找到字段名称,并扩展您当前使用的URL,如上所示。如果它有效,你就完成了。如果没有,您可能需要更新服务器端的代码,以接受该字段作为查询字符串的一部分。



完成同样事情的其他方法更多取决于服务器端代码。例如,许多网站将相关推介ID嵌入网址中,例如:

  http://www.example.com/ 123456 / 

在这种情况下,服务器端代码将目录路径解释为字段并相应地解析它。因为这需要非常特定的服务器端代码来支持它,所以第一种选择可能是您最好的选择。


I'm coding a newsletter and the guy that asked me to do it wants a link in it...all perfect no problems...

Now the problem is that when you click on this link it goes on a page with fields and the guy asked me if it's possible to automatically fill up one of the fields.

The page is a subscription page for some services and this guy wants me to fill up the referral field automatically when you land on the page with his email. Is it possible?

Thanks heaps

解决方案

One way to do this is to place the field name and value in the query string. The "query string" is the part of a URL which contains field/value pairs. It is separated from the page address by a ? followed by field=value pairs separated by & characters. For example,

http://www.example.com

...would become...

http://www.example.com?fieldName=fieldValue

In order for this to work, the page must parse the field as part of the HTTP GET request and then return the value as a pre-filled field. If the form is properly validated at the server side then it usually already has this capability of parsing fields and retaining their values across multiple submissions of the same form. This is because doing so allows the page to be redrawn with an error message if some fields are blank or have invalid values.

This is very easy to test - just find the field name in the page source and extend the URL you are currently using as shown above. If it works you are done. If not, you may need to get the code on the server side updated to accept the field as part of the query string.

Other ways to accomplish the same thing are more dependent on the server-side code. For example, many sites embed the associate referral ID in the URL such as:

http://www.example.com/123456/

In this case, server-side code interprets the directory path as a field and parses it accordingly. Because this requires very specific server-side code to support it, the first option is probably your best bet.

这篇关于创建一个自动填充目标页面上的字段的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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