admin管理员组文章数量:1279043
Basically, what I am doing is generating a PDF file on the server and showing it in the browser via javascript like this:
file = new window.Blob([data], { type: 'application/pdf' });
var fileUrl = URL.createObjectURL(file);
var wnd = window.open(fileUrl, "_blank", "location=no, fullscreen=yes, scrollbars=auto, width=" + screen.width + ",height=" + screen.height);
All this works fine but every browser is showing an ugly subtitle (something like this): blob:2da57927-311e-4b3d-a261-d2679074802c
Is there any way to get rid of this subtitle or to replace it with something meaningful?
Edited: Here is a screen capture of the improved code (after applying VisioN's suggestion):
Basically, what I am doing is generating a PDF file on the server and showing it in the browser via javascript like this:
file = new window.Blob([data], { type: 'application/pdf' });
var fileUrl = URL.createObjectURL(file);
var wnd = window.open(fileUrl, "_blank", "location=no, fullscreen=yes, scrollbars=auto, width=" + screen.width + ",height=" + screen.height);
All this works fine but every browser is showing an ugly subtitle (something like this): blob:2da57927-311e-4b3d-a261-d2679074802c
Is there any way to get rid of this subtitle or to replace it with something meaningful?
Edited: Here is a screen capture of the improved code (after applying VisioN's suggestion):
Share Improve this question edited Jun 27, 2014 at 14:09 zszep asked Jun 27, 2014 at 12:33 zszepzszep 4,4835 gold badges41 silver badges58 bronze badges 3-
I doubt if you can do this anyhow in cross-browser way, if only you don't display a plain HTML page with maximised
<iframe>
element, that outputs the blob contents. – VisioN Commented Jun 27, 2014 at 12:37 - Save it somewhere and pass the link (server or S3) – Lukasz Madon Commented Jun 27, 2014 at 12:38
- Have you some short sample code how to do this? – zszep Commented Jun 27, 2014 at 12:38
2 Answers
Reset to default 7As I mentioned in the ments, one possible way is to make an <iframe>
in the popup window, that displays the current Blob
data, and to style the popup as you wish:
var win = open('', 'name', 'height=300, width=300'),
iframe = document.createElement('iframe'),
title = document.createElement('title'),
file = new Blob([data], { type: 'application/pdf' }),
fileUrl = URL.createObjectURL(file);
title.appendChild(document.createTextNode('Nice title :)'));
iframe.src = fileUrl;
iframe.width = '100%';
iframe.height = '100%';
iframe.style.border = 'none';
win.document.head.appendChild(title);
win.document.body.appendChild(iframe);
win.document.body.style.margin = 0;
DEMO: http://jsfiddle/MeY9e/
You can simply add a settimeout to change the page title after the blob has been loaded in the new tab like this -
newTab.location.href = URL.createObjectURL(blob);
setTimeout(function() {
newTab.document.title = blob.name;
}, 10);
本文标签: javascriptHow to prevent blobguid in browser titleStack Overflow
版权声明:本文标题:javascript - How to prevent blob + guid in browser title - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741275033a2369678.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论