mercredi 24 juin 2015

Disabling javascript code on iPad only

I have a pretty large script in my page that seems to be crashing my site on iPads. It's a vertical image carousel that runs on intervals and it involves 5 functions. I can remove the script and then the site loads fine on iPad but the carousel no longer works (which is OK on ipad).

How can I disable this script on iPad?

I tried using this: http://ift.tt/pdCCtw

basically:

<script>
var isiPad = navigator.userAgent.match(/iPad/i); 

if ( !isiPad ) {
//large script goes here with multiple functions
}

</script>

Do I need to wrap each individual function in "if ( !isiPad ){} ? Is there any way I can only allow the entire script to run if the device being used is NOT an ipad?

Thanks in advance for help!

Aucun commentaire:

Enregistrer un commentaire