2017-04-12 17 views
0

javascript/jquery/bootstrapをダウンロードせずにmodalでpdfを開く方法は? 私はブートストラップモーダルを使用しようとしていますが、動作しません。 なぜですか?私は、ソース以下のコードを使用してい - http://bootsnipp.com/snippets/P3Vvmjavascript/jquery/bootstrapを使用してモーダルでpdfを開く方法は?

<div class="container"> 
    <div class="row"> 
     <h2>Showing PDF in popup modal preview using Bootstrap Easy Modal Plugin</h2> 
     <a class="btn btn-primary view-pdf" href="http://wellnesshabitat.nexmapp.com/wp-content/uploads/2017/04/License.pdf">View PDF</a>   
    </div> 
</div> 

jqueryのコードを: /* *このプラグイン */ (関数(A){a.createModal =関数(B){デフォルト=ですclose button:true、scrollable:false}; var b = a.extend({}、defaults、b); var c =(b.scrollable === html + = ''; html + = ''; html + = ''; html + = 'x' ; if(b.title.length> 0){html + = '' + b.title + ""} html + = ""; html + = '"; html + = b.message; html + =" "; html + =' '; if prepend(html); a(b.closeButton === true){html + = '閉じる'} html + = ""; html + = ""; html + = " "#myModal")。modal()。on( "hidden.bs.modal"、fun ction(){a(this).remove()})}})(jQuery);

/* 
* Here is how you use it 
*/ 
$(function(){  
    $('.view-pdf').on('click',function(){ 
     var pdf_link = $(this).attr('href'); 
     var iframe = '<div class="iframe-container"><iframe src="'+pdf_link+'"></iframe></div>' 
     $.createModal({ 
     title:'My Title', 
     message: iframe, 
     closeButton:true, 
     scrollable:false 
     }); 
     return false;   
    });  
}) 
    .iframe-container {  
    padding-bottom: 60%; 
    padding-top: 30px; height: 0; overflow: hidden; 
} 

.iframe-container iframe, 
.iframe-container object, 
.iframe-container embed { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
} 
+1

コードの一部を入力してください。 –

答えて

0

これまでのコードをご記入ください。また、で、デフォルトではmodalでbootstrap/jQueryを表示できません。より良い答えをより多くの情報を提供してください

https://docs.google.com/gview?embedded=true&url=" + LinkToThePDFFile

:モーダル内のiframeを使用して、このGDocsリンクをロード

  1. のlibを使用しlike this one
  2. を:次の2つのオプションがあります。

0
1) Checkout PDFObject JS, 

     <script src="https://github.com/pipwerks/PDFObject/blob/master/pdfobject.min.js"></script> 

    1)PDFObject embeds PDF files into HTML documents. https://pdfobject.com/ 

    2) Easy Modal Plugin for Bootstrap. http://bootsnipp.com/snippets/VX7EN 
    3) Using jQuery Dialog Modal Popup Window. 

    Hope it helped. 



    [1]: http://bootsnipp.com/snippets/VX7EN 
関連する問題