简体   繁体   English

html2canvas在godaddy上托管后无法正常工作

[英]html2canvas not working after hosting on godaddy

i use html2canvas to generate my table as pdf, when i run on my visual studio, it works fine, but after i publish on godaddy, first javascript pop up message appear, but the pdf never downloaded, my adblock plus is disabled and i using chrome and edge to access it, by the way this is also my first time to hosting a web 我使用html2canvas以pdf格式生成表格,当我在自己的Visual Studio上运行时,它工作正常,但是在Godaddy上发布后,出现了第一个javascript弹出消息,但是pdf从未下载,我的adblock plus被禁用,我使用chrome和edge来访问它,顺便说一句,这也是我第一次托管网络

<head runat="server">
    <title></title>

    <link rel="stylesheet" href="css/Style.css" />
    <script src="jsfiles/html2canvas.min.js"></script>
    <script src="jsfiles/pdfmake.min.js"></script>

    <script type="text/javascript" src="js/js.js"></script>
    <script type="text/javascript" src="js/jspdf.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">

        function Export() {
            alert("Sabar Ya!!!");
            html2canvas(document.getElementById('perubahantarif'), {
                onrendered: function (canvas) {
                    var data = canvas.toDataURL();
                    var docDefinition = {
                        content: [{
                            image: data,
                            width: 500
                        }]
                    };
                    pdfMake.createPdf(docDefinition).download("APPEM.pdf");
                    alert("Mendownload");
                }
            });
        }
//my table id
<table id="perubahantarif">

//my button
<input type="button" id="btnExport" value="Export" onclick="Export()" class="auto-style2" />

i put all of them inside the same aspx page 我把它们都放在同一个aspx页面中

i expect the pdf will downloaded like in my local visual studio the error is that pdf never downloaded when i publish to godaddy 我希望pdf会像在我本地的Visual Studio中一样下载,错误是当我发布到godaddy时pdf从未下载

Okay after you updated question and comments, your src attribute works fine when you are doing locally. 好的,在更新问题和评论之后,在本地执行操作时,src属性可以正常工作。

So you need to change them to current directory path, so use these changes in code (a dot forward slash prefixed) 因此,您需要将它们更改为当前目录路径,因此请在代码中使用这些更改(带点正斜杠的前缀)

<script src="./jsfiles/html2canvas.min.js"></script>
    <script src="./jsfiles/pdfmake.min.js"></script>

    <script type="text/javascript" src="./js/js.js"></script>
    <script type="text/javascript" src="./js/jspdf.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM