mercredi 23 mars 2016

javascript indexOf check in if statement

Having some difficulty getting this code to work. Essentially, I want to check if the referring url is coming from the /mobile directory and if not and the screen is a mobile device I want to redirect to the mobile site.

<script type="text/javascript">
if(window.location.href.indexOf("document.write(document.referrer)") > -1 &&
    screen.width <= 699) {
    document.location = "/mobile/mobile_home.asp";
}

</script>

The code is currently placed in the head of the main home.asp.

Aucun commentaire:

Enregistrer un commentaire