How to open the newly created image in a new tab?

前端 未结 4 1067
无人及你
无人及你 2020-12-05 17:47

Below code creates the image in the bottom of the same page. How to display that image into a new tab/window instead of displaying in the same page?

succes         


        
4条回答
  •  温柔的废话
    2020-12-05 18:30

    Latest solution - works 2019-10.

    Open image in new tab.

    let data = 'data:image/png;base64,iVBORw0KGgoAAAANS';
    let w = window.open('about:blank');
    let image = new Image();
    image.src = data;
    setTimeout(function(){
      w.document.write(image.outerHTML);
    }, 0);
    

    https://stackoverflow.com/a/58615423/2450431 https://stackoverflow.com/a/46510790/2450431 https://stackoverflow.com/a/27798235/2450431

提交回复
热议问题