0
I’m picking up an URL item with this code :
function GetQueryString(a)
{
a = a || window.location.search.substr(1).split('&').concat(window.location.hash.substr(1).split("&"));
if (typeof a === "string")
a = a.split("#").join("&").split("&");
if (!a) return {};
var b = {};
for (var i = 0; i < a.length; ++i)
{
var p = a[i].split('=');
if (p.length != 2) continue;
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
}
return b;
}
var qs = GetQueryString();
qs["item"]; // Item que eu estou pegando da url ex:
https://meusite.com/pagina.php?item=(valor que eu quero pegar)
And after you effect this process, I would like that with the value obtained from
variable "Qs" concatenate with the link of the new page that would be redirected after 3 seconds, I am using this code:
setTimeout("document.location = 'https://www.meusite.com/pagina.php?item='" + `qs['item']`,3000);
How can I fix this code ?
Thanks so much @mauhumor, one more question if you could help me, as I could for that
qs.item
within an html attribute such as the attribute I am using isdata-channel-external-id="(valor da url aqui dentro)"
– Charlie Sheen
You can use the "setAttribute" method documented here: http://www.w3schools.com/jsref/met_element_setattribute.asp
– mau humor
'Cause I was trying this one before but it wasn’t working out here, I was doing the following, I did this job
function urlid() {
 document.getElementsByTagName("BUTTON")[0].setAttribute("data-channel-external-id", "qs.item"); }
and the attribute inside the HTMLdata-channel-external-id="urlid()"
but I couldn’t, which you think I might be doing wrong?– Charlie Sheen