2

Possible Duplicate:
Detect if device is iOS

Here is what I want to do:

<script type="text/javascript">
        // Run This code if device is iOS based
        window.addEventListener('DOMContentLoaded',function() {
            $("body").queryLoader2({
                barColor: "#37201b",
                backgroundColor: "#c2a875",
                percentage: true,
                barHeight: 5,
                completeAnimation: "grow"
            });
       });
        // if it is not iOS run this code
        $(document).ready(function () {
            $("body").queryLoader2({
                barColor: "#37201b",
                backgroundColor: "#c2a875",
                percentage: true,
                completeAnimation: "grow",
                barHeight: 5
            });
        });
        </script>

Instead of comments what do I write to make it work?

Community
  • 1
  • 1
Ilja
  • 35,872
  • 66
  • 218
  • 401

1 Answers1

5
jQuery(document).ready(function($){
    var deviceAgent = navigator.userAgent.toLowerCase();
    var agentID = deviceAgent.match(/(iPad|iPhone|iPod)/i);
    if (agentID) {     
        window.addEventListener('DOMContentLoaded',function() {
            $("body").queryLoader2({
                barColor: "#37201b",
                backgroundColor: "#c2a875",
                percentage: true,
                barHeight: 5,
                completeAnimation: "grow"
            });
       });     
    }
    else
    {
        $(document).ready(function () {
            $("body").queryLoader2({
                barColor: "#37201b",
                backgroundColor: "#c2a875",
                percentage: true,
                completeAnimation: "grow",
                barHeight: 5
            });
        });
    }
});
Dan Barzilay
  • 4,430
  • 3
  • 25
  • 38