Window.print() 不采用当前 url [英] Window.print() does not take the current url

查看:39
本文介绍了Window.print() 不采用当前 url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码.根据此代码,将打开新窗口并提供给定的 url 源.但是打印的时候显示about:blank正在打印.页面加载正确.在加载之前,页面 url 也是 about:blank.但它很快就会更改为给定的网址.

I am using the following code. According to this code, new window will open with the source of url given. But when printing, it is showing about:blank is printing. The page loads correctly. Before loading, the page url is also about:blank. But it changes to the given url soon.

var url="http://localhost:8080/hiring/docs/Keneth%20_1340800082258/Keneth%20_resume_1340800082258.pdf";
var printwindow = window.open(url, '_blank', 'fullScreen=yes');
//setTimeout('2000');
printwindow.focus();
printwindow.print();

推荐答案

我猜 window.print() 在页面实际加载之前运行,因为执行代码的下一个命令需要几微秒,但页面不会在几微秒内加载,这就是它打印空白页面的原因,请在文档加载事件后尝试打印.

I guess window.print() runs before the page is actually loaded, because it takes microseconds to execute next command of your code, but the page won't load in microseconds, that's why it prints blank page, try print it after document load event.

修复

我注意到您刚才尝试打印 PDF,我认为不能仅仅因为您可以在浏览器中看到它就打印 PDF 文件.它只是一个Adobe Reader插件,因为同样的原因你不能在页面上打印flash电影

I have noticed that you tries to print a PDF just now, I don't think that it is possible to print the PDF file just because you can see it in the browser. It's just an Adobe Reader plugin, because of the same reason you can't print the flash movies on the page

这篇关于Window.print() 不采用当前 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆