在JSFiddle上工作,但不在本地工作?

warfo09


这个jsfiddle对我来说很好用http://jsfiddle.net/xzZ7n/1/
但是,当我尝试在本地或从Sharepoint运行它时,按pdf按钮没有任何反应。
知道为什么会这样吗?
这是我的代码:

    <!DOCTYPE html>
    <html>
    <head>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <title> - jsFiddle demo</title>
      
      <script type='text/javascript' src='//code.jquery.com/jquery-git.js'></script>
      
      
      
      
      <link rel="stylesheet" type="text/css" href="/css/result-light.css">
      
        
          <script type='text/javascript' src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
        
      
        
          <link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
        
      
        
          <script type='text/javascript' src="http://mrrio.github.io/jsPDF/dist/jspdf.debug.js"></script>
        
      
      <style type='text/css'>
        
      </style>
      
    </head>
    <body>
      <div id="customers">
        <table id="tab_customers" class="table table-striped">
            <colgroup>
                <col width="20%">
                    <col width="20%">
                        <col width="20%">
                            <col width="20%">
            </colgroup>
            <thead>
                <tr class='warning'>
                    <th>Country</th>
                    <th>Population</th>
                    <th>Date</th>
                    <th>Age</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Chinna</td>
                    <td>1,363,480,000</td>
                    <td>March 24, 2014</td>
                    <td>19.1</td>
                </tr>
                <tr>
                    <td>India</td>
                    <td>1,241,900,000</td>
                    <td>March 24, 2014</td>
                    <td>17.4</td>
                </tr>
                <tr>
                    <td>United States</td>
                    <td>317,746,000</td>
                    <td>March 24, 2014</td>
                    <td>4.44</td>
                </tr>
                <tr>
                    <td>Indonesia</td>
                    <td>249,866,000</td>
                    <td>July 1, 2013</td>
                    <td>3.49</td>
                </tr>
                <tr>
                    <td>Brazil</td>
                    <td>201,032,714</td>
                    <td>July 1, 2013</td>
                    <td>2.81</td>
                </tr>
            </tbody>
        </table>
    </div>
    <button onclick="javascript:demoFromHTML();">PDF</button>
      
    
    
    <script type='text/javascript'>//<![CDATA[ 
    
    function demoFromHTML() {
        var pdf = new jsPDF('p', 'pt', 'letter');
        // source can be HTML-formatted string, or a reference
        // to an actual DOM element from which the text will be scraped.
        source = $('#customers')[0];
    
        // we support special element handlers. Register them with jQuery-style 
        // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
        // There is no support for any other type of selectors 
        // (class, of compound) at this time.
        specialElementHandlers = {
            // element with id of "bypass" - jQuery style selector
            '#bypassme': function (element, renderer) {
                // true = "handled elsewhere, bypass text extraction"
                return true
            }
        };
        margins = {
            top: 80,
            bottom: 60,
            left: 40,
            width: 522
        };
        // all coords and widths are in jsPDF instance's declared units
        // 'inches' in this case
        pdf.fromHTML(
        source, // HTML string or DOM elem ref.
        margins.left, // x coord
        margins.top, { // y coord
            'width': margins.width, // max width of content on PDF
            'elementHandlers': specialElementHandlers
        },
    
        function (dispose) {
            // dispose: object with X, Y of the last line add to the PDF 
            //          this allow the insertion of new lines after html
            pdf.save('Test.pdf');
        }, margins);
    }
    //]]>  
    
    </script>
    
    
    </body>
    
    
    </html>

知道为什么不起作用吗?谢谢!

斯蒙夫

包含在其中的大多数依赖项URL<head />都已损坏,因为您省略了一部分:您需要添加一些http://以获得有效的远程URL。

                            here ------|
<head>                                 v
  <script type='text/javascript' src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
  <!-- Same thing for other libraries you use... -->
</head>

您也忘记在<head>标签的开头包含jQuery

<head>
  <script type="text/javascript" src="http://code.jquery.com/jquery-git.js"></script>
</head>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在JSFiddle上工作,但不在本地工作?

来自分类Dev

Font Awesome在本地工作,但不在Heroku上工作

来自分类Dev

代码在本地工作,但不在JSFiddle中工作

来自分类Dev

jQuery Toggle不在本地和我的网站上工作,但在jsFiddle上工作?

来自分类Dev

Bootstrap在本地主机上工作,但不在联机服务器上工作

来自分类Dev

AJAX postdata 在本地主机上工作但不在(Apache)服务器上工作

来自分类Dev

javascript 在本地服务器上工作,但不在实时服务器 2 上工作

来自分类Dev

jQuery在jsfiddle上工作但不在我的服务器上

来自分类Dev

Devise Login在Localhost上工作,但不在Production上工作

来自分类Dev

ASP.Net LinkButton在本地工作,但不在服务器上工作

来自分类Dev

PHP页面在本地工作,但不在服务器上工作

来自分类Dev

jQuery .click(function(){})在本地工作,但不在服务器上工作

来自分类Dev

在本地工作,但不在生产上工作UnsatisfiedDependencyException创建名称为'webSecurityConfiguration的bean

来自分类Dev

Puppeteer 脚本在本地工作,但不在 EC2 AWS 上工作

来自分类Dev

使用CORS的LocomotiveJs的Rest API。在本地计算机上工作,但不在Amazon或Heroku上工作

来自分类Dev

“插入不存在的地方” - 在本地 (5.6.35) 上工作但不在服务器 (5.7.22) 上工作 - 未显示错误

来自分类Dev

RichTextBox 在本地服务器上工作,但不在 Azure Web API 服务器上工作

来自分类Dev

URL重写在本地但不在服务器上工作

来自分类Dev

Cake PHP缺少帮助程序,在本地但不在远程上工作

来自分类Dev

本地通知在 ios 模拟器上工作但不在设备上

来自分类Dev

SP 在本地主机上工作,但不在实时服务器上

来自分类Dev

JS 代码在本地主机上工作但不在生产上

来自分类Dev

Curl Scraper 在本地主机上工作但不在在线服务器上

来自分类Dev

Glimpse在本地工作,但不能在Azure上工作

来自分类Dev

表单页面在本地工作,但不能在Heroku上工作?

来自分类Dev

TCPDF在本地工作,但不在线

来自分类Dev

$('form')。serialize()在本地返回空白,在jsFiddle上工作正常

来自分类Dev

Jquery 在控制台上工作但不在页面上

来自分类Dev

OSG:GLSL Shader在AMD上工作,但不在NVIDIA上工作

Related 相关文章

  1. 1

    在JSFiddle上工作,但不在本地工作?

  2. 2

    Font Awesome在本地工作,但不在Heroku上工作

  3. 3

    代码在本地工作,但不在JSFiddle中工作

  4. 4

    jQuery Toggle不在本地和我的网站上工作,但在jsFiddle上工作?

  5. 5

    Bootstrap在本地主机上工作,但不在联机服务器上工作

  6. 6

    AJAX postdata 在本地主机上工作但不在(Apache)服务器上工作

  7. 7

    javascript 在本地服务器上工作,但不在实时服务器 2 上工作

  8. 8

    jQuery在jsfiddle上工作但不在我的服务器上

  9. 9

    Devise Login在Localhost上工作,但不在Production上工作

  10. 10

    ASP.Net LinkButton在本地工作,但不在服务器上工作

  11. 11

    PHP页面在本地工作,但不在服务器上工作

  12. 12

    jQuery .click(function(){})在本地工作,但不在服务器上工作

  13. 13

    在本地工作,但不在生产上工作UnsatisfiedDependencyException创建名称为'webSecurityConfiguration的bean

  14. 14

    Puppeteer 脚本在本地工作,但不在 EC2 AWS 上工作

  15. 15

    使用CORS的LocomotiveJs的Rest API。在本地计算机上工作,但不在Amazon或Heroku上工作

  16. 16

    “插入不存在的地方” - 在本地 (5.6.35) 上工作但不在服务器 (5.7.22) 上工作 - 未显示错误

  17. 17

    RichTextBox 在本地服务器上工作,但不在 Azure Web API 服务器上工作

  18. 18

    URL重写在本地但不在服务器上工作

  19. 19

    Cake PHP缺少帮助程序,在本地但不在远程上工作

  20. 20

    本地通知在 ios 模拟器上工作但不在设备上

  21. 21

    SP 在本地主机上工作,但不在实时服务器上

  22. 22

    JS 代码在本地主机上工作但不在生产上

  23. 23

    Curl Scraper 在本地主机上工作但不在在线服务器上

  24. 24

    Glimpse在本地工作,但不能在Azure上工作

  25. 25

    表单页面在本地工作,但不能在Heroku上工作?

  26. 26

    TCPDF在本地工作,但不在线

  27. 27

    $('form')。serialize()在本地返回空白,在jsFiddle上工作正常

  28. 28

    Jquery 在控制台上工作但不在页面上

  29. 29

    OSG:GLSL Shader在AMD上工作,但不在NVIDIA上工作

热门标签

归档