【问题标题】:html2canvas: capturing screenshot of remote websitehtml2canvas:捕获远程网站的屏幕截图
【发布时间】:2014-02-19 18:47:28
【问题描述】:

伙计们,

我是 js 新手,我无法捕获和截取远程网站的屏幕截图。有人能指出我正确的方向吗

我不断收到此错误:

Uncaught TypeError: Object [object Object] has no method 'html2canvas' index.php:4201 捕获 index.php:4201 点击

我的代码是 index.php

<html>
<head>
<title>Hawk-Eye: Have a look at what others are upto</title>
<script type="text/javascript"        src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://localhost/Hawk-eye/html2canvas.js"></script>
<script type="text/javascript" src="http://localhost/Hawk-    eye/jquery.plugin.html2canvas.js"></script>
</head>
<body>

<div id="target">
<?php

 $homepage= file_get_contents('http://www.yahoo.com');
 echo $homepage;
?>
</div>

<form method="POST" enctype="multipart/form-data" action="save.php" id="myForm">
<input type="hidden" name="img_val" id="img_val" value="" />
</form>

<script type="text/javascript">

function capture() {
    $('#target').html2canvas({
        onrendered: function (canvas) {
            //Set hidden field's value to image data (base-64 string)
            $('#img_val').val(canvas.toDataURL("image/png"));
            //Submit the form manually
            document.getElementById("myForm").submit();
        }
    });
}

</script>

<input type="submit" value="Take Screenshot" onclick="capture();" />
</body>
</html>

【问题讨论】:

  • http://localhost/Hawk- eye/jquery.plugin.html2canvas.js 你确定这是正确的路径?
  • dev-null-dweller:我认为是路径问题。 Php-storm 通过从正确的路径导入它进行了自动修复。我觉得自己像个菜鸟:/

标签: php javascript html2canvas


【解决方案1】:

下载html4canvas并导入

<script type="text/javascript" src="html2canvas.js?rev032"></script> 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-22
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 2022-01-13
    • 1970-01-01
    • 2015-06-14
    相关资源
    最近更新 更多