简体   繁体   English

单击链接后自动将文本输入到外部网站上的文本框

[英]Auto inputting text to textbox on exterior website after clicking link

I was wondering if there would be a way to have or implement so that when a link is clicked on my website, it takes you to another website with a textbox and auto inputs a number or string. 我想知道是否有某种方法可以使当我的网站上的链接被单击时,它会将您带到带有文本框的另一个网站并自动输入数字或字符串。

What I essentially am trying to do with more detail. 我实质上是在尝试做更多细节。

I have a website that advertises product. 我有一个宣传产品的网站。 It's a website that sells things based off of commission. 这是一个根据佣金出售商品的网站。 I have a link on the website that links to another business website and has an input box to input an ID number in order for the website to know which item they are buying based off of an ID number, when the link is clicked, it takes them there and they would manually have to type it in. I was wondering if there was a way that when they click the corresponding link, it would take them to said website and automatically add the ID into the textbox so they wouldn't have to memorize or copy/paste. 我在网站上有一个链接,该链接链接到另一个商业网站,并且有一个输入框,用于输入ID号,以便该网站根据ID号知道他们要购买的商品,单击该链接时,他们在那里,他们将不得不手动输入。我想知道是否有一种方法,当他们单击相应的链接时,它将带他们到所述网站并自动将ID添加到文本框中,这样他们就不必记住或复制/粘贴。

Any help is greatly appreciated. 任何帮助是极大的赞赏。 Thank you for reading this. 谢谢您阅读此篇。

You can pass variable through URL 您可以通过URL传递变量

http://wwww.example.com/index.html?var=yournumber http://wwww.example.com/index.html?var=您的号码

You can get that var using PHP GET method or Jquery 您可以使用PHP GET方法或Jquery获取该变量

jQuery jQuery的

var url      = window.location.href; 
var number = url.substr(val.indexOf("?") + 1);

PHP 的PHP

 $number = $_GET['var'];

Remeber one thing : Inorder to achieve this you must have access to the second website. 记住一件事 :为了实现这一点,您必须有权访问第二个网站。 You can retrieve variable from second site only if you have access to that site.. 仅当您有权访问第二个站点时,才能从该站点检索变量。

jQuery("#id of input field").val(number);

jQuery("#id of input field").val("<?php echo $number; ?>");

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

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