Hocke_sweden
asked on
Change detect mobile browser
I have a javascript to detect moible browser, but I want to change script from
mdetect.js to detectmobilebrowser.js but can't get it to work.
Can someone help me?
The script check if its a mobile browser and then redirect the to a mobile webb page, but if the webb address is for example www.aftonbladet.se?frMobilsajten
detectmobilebrowser.js
mdetect.js to detectmobilebrowser.js but can't get it to work.
Can someone help me?
The script check if its a mobile browser and then redirect the to a mobile webb page, but if the webb address is for example www.aftonbladet.se?frMobilsajten
<script type="text/javascript" src="mdetect.js"></script>
<script type="text/javascript">
frMobilsajt = window.location.search.substring(1);
var mobil=getCookie("mobil");
if (mobil==null || mobil=="" || mobil == "undefined")
{
if (DetectTierIphone()) {
var exdate=new Date();
// exdate.setDate(exdate.getDate() + 1)
exdate.setMinutes( exdate.getMinutes() + 5)
document.cookie="mobil=ja;expires="+exdate.toUTCString();
if (frMobilsajt!="frMobilsajten")
{
document.location = "http://m.aftonbladet.se";
}
}
}
else
{
//document.cookie="mobil='nej';expires=Thu, 01-Jan-70 00:00:01 GMT;";
}
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
}
</script>
mdetect.jsdetectmobilebrowser.js
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I try to be a little bit clearer
The script
<script type="text/javascript" src="detectmobilebrowser.j s"></scrip t> works alone but not with
the rest of the code
The script
<script type="text/javascript" src="mdetect.js"></script> works with the rest of the code
detectmobilebrowser and mdetect do the same= they detect, but I cant get detectmobilebrowser.js to work togheter with cookie script :)
The script
<script type="text/javascript" src="detectmobilebrowser.j
the rest of the code
The script
<script type="text/javascript" src="mdetect.js"></script>
detectmobilebrowser and mdetect do the same= they detect, but I cant get detectmobilebrowser.js to work togheter with cookie script :)
ASKER
It was not a solution
ASKER
the code: frMobilsajt = window.location.search.sub
But I want both detect browser and cookies, not only detect!