[英]How to view PDF on web, without using browsers builtin PDF viewer?
$('.btn').click(function(){ $('.modal').on('show.bs.modal',function(){ $(this).find('iframe').attr('src','http://www.tutorialspoint.com/php/php_tutorial.pdf') }) $('.modal').modal({show:true}) $('iframe').load(function() { $('.loading').hide(); }); })
<!-- jQuery library --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <!-- Latest compiled JavaScript --> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <button class="btn btn-primary">show modal</button> <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <iframe src="" frameborder="0"></iframe> </div> </div> </div>
這是工作片段。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.