[英]passing actual URL parameters to a button
I'm working on a web funnel , that i would like to track starting from step number #1 .我正在开发一个网络漏斗,我想从第 #1 步开始跟踪。 I'm trying to pass URL parameter for example :我正在尝试传递 URL 参数,例如:
https://mywebsite.com/###/######.html ? https://mywebsite.com/###/######.html ? subid=160445 &eng_source=160445&eng_subid=null&eng_click=1d1ba0f6784b4c36918f087b616a3366 subid=160445 &eng_source=160445&eng_subid=null&eng_click=1d1ba0f6784b4c36918f087b616a3366
i want to pass the "subid=#" to the next destination which is button link so it becomes: https://landing.mywebsite.com/2scstep.html?subid=160445我想将“subid=#”传递到下一个目的地,即按钮链接,所以它变成: https ://landing.mywebsite.com/2scstep.html?subid=160445
or what ever "subid" was there before .或者之前有什么“subid”。
i just need some instruction from where to start adding this or what language should i work with .我只需要一些说明从哪里开始添加这个或我应该使用什么语言。
Thanks A lot .多谢 。
OK, lets imaging you have button on the page, which is好的,让我们想象一下页面上有按钮,这是
<a id="button" href="https://landing.mywebsite.com/2scstep.html">
Take me to new destination
</a>
If I understood you question correctly, you want change the destiantion of the button (href) so it becomes oldhref
+ '?subid=#'
如果我理解你的问题是正确的,你想改变按钮(href)的oldhref
所以它变成oldhref
+ '?subid=#'
It can be done in many techniques in javascript.它可以通过 javascript 中的许多技术来完成。 Simpliest way is to install jquery, and then make smething like this最简单的方法是安装jquery,然后像这样制作
//Wait untill whole document is loaded
$(document).ready(function(){
//You now is on the page, that has url e.g. `href` + `?subid=12345`
// you got to get you subid var to javascript
//Get whole url
var currentHref = window.location.href;
//Get only params part, by splitting string by ? and taking second part
var currentHrefParamsPart = currentHref.split("?")[1];
//Now get all params to array (there can be lots of params)
var paramsArray = currentHrefParamsPart.split("&");
//Now get subid value
var subid = false; //its not known yet
paramsArray.each(function(params){
var key = params.split('=')[0]
if (key == "subid") {
var subid = params.split('=')[1]; //We got it
}
})
//Now you gotta change href attribute of the button if subid was found
if (subid) {
var $button = $("#button");
var oldHref = $button.attr("href"); //get the old href
var newHref = oldHref + "?subid=" + subid; //make new href
$button.attr("href", newHref);
}
})
It is not working code, there could be mistakes or tyopos, I wrote it to give you an idea how to achieve the result, what techiques and languages should be used.它不是工作代码,可能有错误或错别字,我写它是为了让您了解如何实现结果,应该使用哪些技术和语言。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.