I have this issue that allows a user to view the pdf file every time the user's click the button. On the first click, it gives an error of 'Access-Control-Allow-Origin' header is present on the requested resource.
and will display nothing, but when I try it again, it will work and able to view the PDF with the google docs viewer.
The PDF came from the API link and was hosted on storage.googleapis.com which I don't have any control in it.
HTML:
<a href="{{document.document}}" class="btn-open-pdf"><i class="icon icon-eye"></i></a>
Framework7/JQuery:
$(document).on('click', '.btn-open-pdf', function() {
var url = "https://docs.google.com/viewer?url=" + $(this).attr('href');
window.open(url, "_blank", "location=no,toolbar=no,hardwareback=yes");
});
Edit: Popup won't work on mobile devices too due to Pop-up was enabled.