Javascript 从父页面将内容附加到新浏览器窗口

Javascript 从父页面将内容附加到新浏览器窗口,javascript,jquery,html,image,html5-canvas,Javascript,Jquery,Html,Image,Html5 Canvas,我正在尝试将裁剪工具集成到我的网站(js)。此工具将允许用户裁剪图像,在新的浏览器页面中打开它,并使其能够将新图像保存到磁盘中 裁剪代码如下所示: 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

我正在尝试将裁剪工具集成到我的网站(js)。此工具将允许用户裁剪图像,在新的浏览器页面中打开它,并使其能够将新图像保存到磁盘中

裁剪代码如下所示:

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内容附加到NewWindowBody,但它不起作用。我尝试在
窗口之后添加以下内容。打开
命令:

var text = document.createTextNode('Hello World !');
newWindow.document.body.appendChild(text);
但新页面中没有添加任何内容

如何使用父页面中的脚本向新页面的主体添加内容?(Html内容,甚至一些javascript代码)

谢谢

var dataUri=crop\u canvas.toDataURL(“image/png”),
var dataUri = crop_canvas.toDataURL("image/png"),
    newWindow = window.open("about:blank");

newWindow.document.write("<!DOCTYPE html>\n<body><img src='" + dataUri + "' /></body>");

var text = document.createTextNode('Hello World !');
newWindow.document.body.appendChild(text);
newWindow=window.open(“关于:空白”); newWindow.document.write(“\n”); var text=document.createTextNode('Hello World!'); newWindow.document.body.appendChild(文本);