1
我正在嘗試將修剪工具集成到我的網站(js插入resizing cropping images canvas)。這個工具將讓用戶裁剪圖像,在新的瀏覽器頁面中打開它,並讓他有能力將新圖像保存到磁盤中。將內容從父頁面添加到新瀏覽器窗口
裁剪代碼如下:
crop = function(){
//Find the part of the image that is inside the crop box
var crop_canvas,
left = $('.overlay').offset().left - $container.offset().left,
top = $('.overlay').offset().top - $container.offset().top,
width = $('.overlay').width(),
height = $('.overlay').height();
crop_canvas = document.createElement('canvas');
crop_canvas.width = width;
crop_canvas.height = height;
crop_canvas.getContext('2d').drawImage(image_target, left, top, width, height, 0, 0, width, height);
var newWindow = window.open(crop_canvas.toDataURL("image/png"));
}
現在我想追加一些HTML內容newWindow體,但它不工作。我試過後window.open
命令添加如下:
var text = document.createTextNode('Hello World !');
newWindow.document.body.appendChild(text);
但沒有被添加到新的一頁?
如何使用父頁面的腳本添加東西到新頁面的主體? (Html內容,甚至一些JavaScript代碼)
謝謝!