I have tried the following (.myviewer is a div)...
$('.myviewer').click();
and
$('.myviewer').trigger('touchstart');
and
$('.myviewer').trigger('click');
All work on a computer but not an iPad. What am I doing wrong?
Here is what the body of the html page looks like...
<body>
<div class="myviewer" onclick="window.open('myPDFFile.pdf');">Programmatically clicked</div>
</body>
And to round this out 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);
};
});