www.baidu.com/wenzhang/a5170095fad6fde708a563d135e1302b.htm
我想获得上面**a5170095fad6fde708a563d135e1302b** 这个参数,
用于跳转到手机页面
m.baidu.com/show/a5170095fad6fde708a563d135e1302b.htm
跳转手机站已经解决了,这个地址参数怎么获得?
6 个解决方案
#1
'www.baidu.com/wenzhang/a5170095fad6fde708a563d135e1302b.htm'.match(/(\w+)\.htm/)[1]
#2
分割字符串啊
var url = window.location.href.toString();
var x = url.split("/");
var y = x[x.length-1].split(".")[0];
console.log(y);
#3
怎么调用啊?
我的完整代码是
<script src="http://siteapp.baidu.com/static/webappservice/uaredirect.js" type="text/javascript"></script>
<script type="text/javascript">uaredirect("http://m.baidu.com/show/需要截取的地址");</script>
怎么把你所说的那个,加入到 上面 那个 需要截取的地址?
#4
var queryString = function () {
var url = top.window.location.search,
urlData = "",
dataString = [],
dataJson = {},
arr = [];
if (url != "") {
urlData = url.split("?")[1];
dataString = urlData.split("&");
for (var i = 0, len = dataString.length; i < len; i++) {
arr = dataString[i].split("=");
dataJson[arr[0]] = arr[1];
}
}
else {
dataJson = null;
}
return dataJson;
};
var url = top.window.location.search,
urlData = "",
dataString = [],
dataJson = {},
arr = [];
if (url != "") {
urlData = url.split("?")[1];
dataString = urlData.split("&");
for (var i = 0, len = dataString.length; i < len; i++) {
arr = dataString[i].split("=");
dataJson[arr[0]] = arr[1];
}
}
else {
dataJson = null;
}
return dataJson;
};
#5
queryString = function () {
var url = top.window.location.search,
urlData = "",
dataString = [],
dataJson = {},
arr = [];
if (url != "") {
urlData = url.split("?")[1];
dataString = urlData.split("&");
for (var i = 0, len = dataString.length; i < len; i++) {
arr = dataString[i].split("=");
dataJson[arr[0]] = arr[1];
}
}
else {
dataJson = null;
}
return dataJson;
};
#6
稍微学习一下吧,方法和demo都给你列出来了,还有二楼用正则的方法更加简单,学了才有进步啊~
你先要获取那个url,然后再去处理它~
#1
'www.baidu.com/wenzhang/a5170095fad6fde708a563d135e1302b.htm'.match(/(\w+)\.htm/)[1]
#2
分割字符串啊
var url = window.location.href.toString();
var x = url.split("/");
var y = x[x.length-1].split(".")[0];
console.log(y);
#3
分割字符串啊
var url = window.location.href.toString();
var x = url.split("/");
var y = x[x.length-1].split(".")[0];
console.log(y);
怎么调用啊?
我的完整代码是
<script src="http://siteapp.baidu.com/static/webappservice/uaredirect.js" type="text/javascript"></script>
<script type="text/javascript">uaredirect("http://m.baidu.com/show/需要截取的地址");</script>
怎么把你所说的那个,加入到 上面 那个 需要截取的地址?
#4
var queryString = function () {
var url = top.window.location.search,
urlData = "",
dataString = [],
dataJson = {},
arr = [];
if (url != "") {
urlData = url.split("?")[1];
dataString = urlData.split("&");
for (var i = 0, len = dataString.length; i < len; i++) {
arr = dataString[i].split("=");
dataJson[arr[0]] = arr[1];
}
}
else {
dataJson = null;
}
return dataJson;
};
var url = top.window.location.search,
urlData = "",
dataString = [],
dataJson = {},
arr = [];
if (url != "") {
urlData = url.split("?")[1];
dataString = urlData.split("&");
for (var i = 0, len = dataString.length; i < len; i++) {
arr = dataString[i].split("=");
dataJson[arr[0]] = arr[1];
}
}
else {
dataJson = null;
}
return dataJson;
};
#5
queryString = function () {
var url = top.window.location.search,
urlData = "",
dataString = [],
dataJson = {},
arr = [];
if (url != "") {
urlData = url.split("?")[1];
dataString = urlData.split("&");
for (var i = 0, len = dataString.length; i < len; i++) {
arr = dataString[i].split("=");
dataJson[arr[0]] = arr[1];
}
}
else {
dataJson = null;
}
return dataJson;
};
#6
分割字符串啊
var url = window.location.href.toString();
var x = url.split("/");
var y = x[x.length-1].split(".")[0];
console.log(y);
怎么调用啊?
我的完整代码是
<script src="http://siteapp.baidu.com/static/webappservice/uaredirect.js" type="text/javascript"></script>
<script type="text/javascript">uaredirect("http://m.baidu.com/show/需要截取的地址");</script>
怎么把你所说的那个,加入到 上面 那个 需要截取的地址?
稍微学习一下吧,方法和demo都给你列出来了,还有二楼用正则的方法更加简单,学了才有进步啊~
你先要获取那个url,然后再去处理它~