<script type="text/javascript">
$(document).on('click','a',function(){
var url = $(this).attr('href');
var title = $(this).attr('title');
var type = Android_ios();
var parms = GetRequest(url);
var data= JSON.stringify(parms);
event.preventDefault();
if((title==0)||(title==undefined)){
window.location.href=url;
}else if(title==1){
var u = navigator.userAgent;
var isAPP = u.indexOf('AuraApp') > -1 ;
if(isAPP){//在APP内
if(type == 'Android'){
window.android.ghJumpHorizonORCommunity(data);
}else if(type =='iPhone'){
window.prompt('ghJumpHorizonORCommunity',data);
}
}else{
window.location.href=url;
}
}
return false;
});
/**
* [获取URL中的参数名及参数值的集合]
* 示例URL:http://htmlJsTest/getrequest.html?uid=admin&rid=1&fid=2&name=小明
* @param {[string]} urlStr [当该参数不为空的时候,则解析该url中的参数集合]
* @return {[string]} [参数集合]
*/
function GetRequest(urlStr) {
if (typeof urlStr == "undefined") {
var url = decodeURI(location.search); //获取url中"?"符后的字符串
} else {
var url = "?" + urlStr.split("?")[1];
}
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
}
}
return theRequest;
}
function Android_ios(){
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {//安卓手机
return 'Android';
} else if (u.indexOf('iPhone') > -1) {//苹果手机
return 'iPhone';
} else if (u.indexOf('Windows Phone') > -1) {//winphone手机
return 'winphone';
}
}
</script>