In my Wordpress website, I have Visual composer page builder plugin. In that, I am creating a button which if click from apple phone, will redirect to Apple store and if clicked from android will redirect to google play store. I am doing this by a script which I put in visual composer's Raw js element. below is the script:
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
jQuery(function ($) {
$( document ).ready(function() {
$(".custom_button").on("click", function(){
if(navigator.userAgent.toLowerCase().indexOf("android") > -1){ alert('in android');
window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&hl=en';
}
if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){ alert('in iphone');
window.location.href = 'http://itunes.apple.com/';
alert('after iphone');
}
});
});
});
</script>
window.location.href is not working. it doesn't redirect. It runs a script and do alert 'in iphone' and 'after iphone' but it is not redirecting to any store.