admin管理员组文章数量:1289877
I want open new window (with jQuery) and show PDF from base64 content. When I make normal link:
<a href=\"data:application/pdf;base64,'.$answer->shipping_label_content.'\" target=\"blank\">Show PDF</a>
It's all good. But I want automatic open new window with this content and I don't know how :-/
var window = window.open();
var html = "data:application/pdf;base64,'.$answer->shipping_label_content.'";
$(window.document.body).html(html);
I want open new window (with jQuery) and show PDF from base64 content. When I make normal link:
<a href=\"data:application/pdf;base64,'.$answer->shipping_label_content.'\" target=\"blank\">Show PDF</a>
It's all good. But I want automatic open new window with this content and I don't know how :-/
var window = window.open();
var html = "data:application/pdf;base64,'.$answer->shipping_label_content.'";
$(window.document.body).html(html);
Share
Improve this question
asked Mar 30, 2015 at 8:06
Kuba ŻukowskiKuba Żukowski
6633 gold badges11 silver badges16 bronze badges
1 Answer
Reset to default 8You can generate a temp anchor
and click programmatically.
//this trick will generate a temp <a /> tag
var link = document.createElement("a");
link.href = "data:application/pdf;base64,'.$answer->shipping_label_content.'";
//Set properties as you wise
link.download = "SomeName";
link.target = "blank";
//this part will append the anchor tag and remove it after automatic click
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
本文标签: javascriptHow open new window with base64 PDF contentStack Overflow
版权声明:本文标题:javascript - How open new window with base64 PDF content? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741487980a2381493.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论