[英]Hide query string from url when user redirects to page
I am currently using webflow to host my site.我目前正在使用 webflow 来托管我的网站。 In the redirection section on the hosting tab.在托管选项卡上的重定向部分。 I added a 301 redirect query string that redirects to my index, I do this because I wanted to track where do the users come from in my site.我添加了一个重定向到我的索引的 301 重定向查询字符串,我这样做是因为我想跟踪用户来自我网站的哪里。
Read this article and try it out: https://www.newmediacampaigns.com/blog/how-to-track-landing-page-redirects-using-google-analytics阅读这篇文章并尝试一下: https : //www.newmediacampaigns.com/blog/how-to-track-landing-page-redirects-using-google-analytics
So basically it states this:所以基本上它说明了这一点:
So for example i created a redirect /mexico to go to my index with a query string.例如,我创建了一个重定向 /mexico 以使用查询字符串转到我的索引。 Currently it works really well, but i want to know if it is possible that the user does not see the query string when entering from a redirect link.目前它工作得很好,但我想知道用户是否有可能在从重定向链接输入时看不到查询字符串。
For example when user enters by example.com/mexico, the url search bar shows only example.com例如当用户通过example.com/mexico输入时,url搜索栏只显示example.com
I tried hiding it using javascript, but does not work.我尝试使用 javascript 隐藏它,但不起作用。
var testURL = 'myurl';
testURL.split('?')[0];
Any clue?有什么线索吗? or suggestion?或建议?
The only way to do this is with thehistory API - not available in older browsers.做到这一点的唯一方法是使用历史 API - 在旧浏览器中不可用。
The standard way of doing this is这样做的标准方法是
history.pushState("object or state to represent your page", "page title", "/thenewurlpath");
You could add this to your document.ready
callback, EG您可以将此添加到您的document.ready
回调中,EG
$(document).ready(function(){
history.pushState("something", "newtitle", "/thenewpath");
// Whatever else your document.ready callback is doing...
})
Hope this helped :)希望这有帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.