I tried the following (.myviewer is a div) ...
$('.myviewer').click(); and $('.myviewer').trigger('touchstart'); and $('.myviewer').trigger('click');
Everyone works on a computer, but not on an iPad. What am I doing wrong?
Here is what the html page body looks like ...
<body> <div class="myviewer" onclick="window.open('myPDFFile.pdf');">Programmatically clicked</div> </body>
And to get around this, here is my jquery code ...
$(document).ready(function() { var isMobile = { Android : function() { return navigator.userAgent.match(/Android/i) ? true : false; }, BlackBerry : function() { return navigator.userAgent.match(/BlackBerry/i) ? true : false; }, iOS : function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false; }, Windows : function() { return navigator.userAgent.match(/IEMobile/i) ? true : false; }, any : function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows()); } }; if(isMobile.any()) { $('.myviewer').clck(); //this does works on computers but not on iPad }else { var markup = "<object data='myPDFFile.pdf#toolbar=1&navpanes=1&scrollbar=0&page=1&view=FitH' type='application/pdf' width='100%' height='100%'> </object>"; $('.myviewer').append(markup); };
});
jquery triggers ipad
user278859
source share