Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用javascript/jquery/bootstrap在模式中打开pdf?_Javascript_Jquery_Pdf_Model_Bootstrap Modal - Fatal编程技术网

如何使用javascript/jquery/bootstrap在模式中打开pdf?

如何使用javascript/jquery/bootstrap在模式中打开pdf?,javascript,jquery,pdf,model,bootstrap-modal,Javascript,Jquery,Pdf,Model,Bootstrap Modal,如何在无需下载的情况下使用javascript/jquery/bootstrap在模式中打开pdf? 我正在尝试使用引导模式,但它不工作。 为什么? 我正在使用以下源代码- 使用引导简易模式插件在弹出模式预览中显示PDF Jquery代码: /* *这就是插件 */ (函数(a){a.createModal=function(b){defaults={title:,message:“您的消息在这里!”,closeButton:true,可滚动:false};var b=a.extend({}

如何在无需下载的情况下使用javascript/jquery/bootstrap在模式中打开pdf? 我正在尝试使用引导模式,但它不工作。 为什么? 我正在使用以下源代码-


使用引导简易模式插件在弹出模式预览中显示PDF
Jquery代码: /* *这就是插件 */ (函数(a){a.createModal=function(b){defaults={title:,message:“您的消息在这里!”,closeButton:true,可滚动:false};var b=a.extend({},默认值,b);var c=(b.scrollable===true)'style=“max height:420px;overflow-y:auto;”:“”;html='';html='';html+'';html+='';html+='';html+='';html+=”;html+=”;if(b.title.length>0){html+=“”“html+=b.message;html+=”;html+=”;if(b.closeButton===true){html+='Close'}html+=”;html+=”;html+=”;a(“body”).prepend(html);a(“myModal”).modal().on(“hidden.bs.modal”,function(){a(this.remove()}})(jQuery)

/*
*下面是你如何使用它
*/
$(函数(){
$('.view pdf')。在('click',function()上{
var pdf_link=$(this.attr('href');
变量iframe=''
$.CreateModel({
标题:'我的标题',
信息:iframe,
关闭按钮:对,
可滚动:false
});
返回false;
});    
})
.iframe容器{
垫底:60%;
填充顶部:30px;高度:0;溢出:隐藏;
}
.iframe容器iframe,
.iframe容器对象,
.iframe容器嵌入{
位置:绝对位置;
排名:0;
左:0;
宽度:100%;
身高:100%;
}

请向我们展示您目前掌握的代码。另外,默认引导/jQuery时,您不能在模式中显示pdf。您有两个选择:

  • 使用库
  • 在modal内使用iframe并加载此GDocs链接:
  • https://docs.google.com/gview?embedded=true&url=“+LinkToThePDFFile

    请提供更多信息以获得更好的答案。

    1)签出PDFObject JS,
    
        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
    
    1) PDFObject将PDF文件嵌入到HTML文档中。https://pdfobject.com/ 2) 简单的引导模式插件。http://bootsnipp.com/snippets/VX7EN 3) 使用jQuery对话框模式弹出窗口。 希望有帮助。 [1]: http://bootsnipp.com/snippets/VX7EN
    请包括您的相关代码,以及您的代码中不起作用的部分。
    /*
    * 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) 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