[英]URL Paramters carried between pages - how to stop tel: also?
I have this really basic script that changes all the links on my wordpress site to preserve the url param - I use it on wordpress landing pages for my business我有这个非常基本的脚本,可以更改我的 wordpress 网站上的所有链接以保留 url 参数 - 我在 wordpress 登录页面上使用它来为我的业务
var queryString = new URL(window.location).search;
document.querySelectorAll("[href]").forEach(link => {
var current = link.href;
link.href = current + queryString;
});
Eg例如
website.com/?location=Australia
All links on the page will carry over the parameter to whatever href link my visitor clicks页面上的所有链接都会将参数传递给访问者点击的任何 href 链接
/book-online/?location=Australia
/request-a-callback/?location=Australia
However this is obviously changing all my href links, and is changing my tel: links with it.然而,这显然改变了我所有的 href 链接,并改变了我的 tel: 链接。
Is there a way I can make it only change https://?有没有办法让它只改变 https://?
My tel: links look like this我的电话:链接看起来像这样
tel:0293 12329?location=Australia
I have had this code copied and pasted for ages, I know absolutely nothing about javascript and no idea where I found the above code, I've just used it for ages and it works as a quick and easy way for me to track a users progress through my landing pages.我已经复制和粘贴了这段代码很长时间了,我对 javascript 一无所知,也不知道我在哪里找到了上面的代码,我已经用了很长时间了,它是我跟踪用户的一种快速简便的方法通过我的登陆页面取得进展。
Perhaps you could only do this if tel:
is not in the href?如果tel:
不在 href 中,也许你只能这样做?
var queryString = new URL(window.location).search;
document.querySelectorAll("[href]").forEach(link => {
var current = link.href;
if (!current.includes("tel:")) {
link.href = current + queryString;
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.