for iOS webapp <a> tags except to bootstrap modal

69 Views Asked by At
<script>
    if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
        var a=document.getElementsByTagName("a");
        for(var i=0;i<a.length;i++)
        {
            a[i].onclick=function()
            {
                window.location=this.getAttribute("href");
                return false
            }
        }
    }
</script>

<a href="link.php" data-target="#ajax" data-toggle="modal"><i class="fa fa-binoculars">

i use this code for iOS webapp and affect all 'a tag', but this code blocks proper operation to bootstrap modal. how can i this code except for modal?

1

There are 1 best solutions below

0
JP Kim On

I had an exact same issue and the solution was dead simple.

change your <a> tag to <div>. that's it.

like this:

<div href="link.php" data-target="#ajax" data-toggle="modal"><i class="fa fa-binoculars">

the script works only on <a> tag, so you can avoid the modal action by change the tag different to <a>...