如何删除自动作为后缀附加到 url 的“&m=0”

How to remove ‘&m=0’ which automatically getting attached as suffix to url

这件事只发生在移动端。 例如 www.example.com&m=0

我正在使用一个脚本将我所有的 link 重定向到一个特定的页面,这是一个确认页面,用户在点击“确认”时只会被重定向。 www.santhaledisom.com/p/confirmation.html?=‘www.yourcontent.com’ 只有在点击“确认”按钮后,他们才会被重定向到 www.mycontent.com。

但它实际上看起来是“www.mycontent.com&m=0”,因此 link 不起作用

这个东西在桌面版本上运行良好,但在移动设备上使用时却不行。 我的网站是基于 Blogger 平台的,即使关闭 Blogger 的移动模板,它仍然会发生。

Confirmation.html 页面有按钮 (Id=myButton)

    <script>
   //get a reference to the element 
    var myBtn = document.getElementById('myButton'); 
    var href = document.location.href; 
    var link = href.split('?=')[1]; 
    //add event listener 
    myBtn.addEventListener('click', function(event)
    { 
    window.location.href="http://" link; });

</script>

我想这可能是移动版和桌面版之间切换的原因 并将“m=0”添加到我的全部 url.

 var curl = window.location.href;if (curl.indexOf('m=1') != -1) {curl = curl.replace('m=1', 'm=0');window.location.href = curl;

m=0 替换为空字符串。

var curl = window.location.href;
if (curl.indexOf('m=1') != -1) {
  curl = curl.replace('m=1', '');
  window.location.href = curl;
}

首先,您不能在移动设备上从 link 中删除 m=1m=0,这是所有博主 blogspot 的强制性要求。

您的重定向 link 应该有一个查询名称,您应该将前缀脚本中的重定向 link 从 ?='www.yourcontent.com' 更改为类似 ?link=www.yourcontent.com 的名称。

现在,如果您有这样的 link: /p/confirmation.html?link=www.yourcontent.com&m=0,您可以轻松提取目标 link 而无需删除 m=1m=0,使用这些简单的代码行:

var myBtn = document.getElementById('myButton'),
    TargetLink;

location.search.substring(1).split('&').forEach(function(par){
    var query = par.split('=');
    if(query[0]==='link'){ TargetLink = query[1] }
});

myBtn.addEventListener('click', function(){
    window.location.href = location.search ? 'http://' + TargetLink : '#';
});