如何删除“& m = 0",后者会自动作为后缀附加到网址 [英] How to remove ‘&m=0’ which automatically getting attached as suffix to url
问题描述
这件事仅在手机上使用时才发生.例如www.example.com& m = 0
This thing is happening only in using in mobile. e.g www.example.com&m=0
我正在使用脚本将所有链接重定向到特定页面,该页面是确认页面,在该页面上,用户在单击确认"时仅会被重定向.www.santhaledisom.com/p/confirmation.html?=‘www.yourcontent.com’仅在单击确认"按钮后,它们才会重定向到www.mycontent.com.
I’m using a script to redirect my all links to a particular page which is a confirmation page, where user when click on ‘confirm’ then only they get redirected. www.santhaledisom.com/p/confirmation.html?=‘www.yourcontent.com’ They are redirected to www.mycontent.com only after clicking on ‘confirm’ button.
但是它实际似乎是"www.mycontent.com& m = 0",因此链接不起作用
But it actual appears to be ‘www.mycontent.com&m=0’ and as a result link doesn’t work
在桌面版本上可以正常运行,但在移动设备上无法正常运行.我的网站基于Blogger平台,即使关闭了Blogger的移动模板,它仍然会发生同样的情况.
This thing is working on fine on desktop version but not in while using in mobile. My site is based on Blogger platform, even when blogger’s mobile template is switched off it still happens same.
Confirmation.html页面具有按钮(Id = myButton)
Confirmation.html page has button (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".
I guess this might be the thing that switches between mobile and desktop version And add ‘m=0’ to my all url.
var curl = window.location.href;if (curl.indexOf('m=1') != -1) {curl = curl.replace('m=1', 'm=0');window.location.href = curl;
推荐答案
首先,您无法从移动设备的链接中删除 m = 1
或 m = 0
,所有博客博客都必须这样做.
First of all, you cannot remove m=1
or m=0
from link in mobile, it's an obligatory on all blogger blogspots.
您的重定向链接应该有一个查询名称,您应该将前缀脚本中的重定向链接从?='www.yourcontent.com'
更改为类似的?link = www.yourcontent.com
.
your redirect link should has a name for query, you should change your redirect link in prefix script from ?='www.yourcontent.com'
to something like that ?link=www.yourcontent.com
.
现在,如果您有这样的链接:/p/confirmation.html?link=www.yourcontent.com&m=0
,您可以轻松提取目标链接,而无需删除 m = 1
或 m = 0
,请使用以下简单的代码行:
now if you have a link like that:
/p/confirmation.html?link=www.yourcontent.com&m=0
, you can easily extract target link and you don't need to remove m=1
or m=0
, use these simple lines of code:
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 : '#';
});
这篇关于如何删除“& m = 0",后者会自动作为后缀附加到网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!