简体   繁体   English

Internet Explorer 9-网页标题(document.title)未显示在印刷品上

[英]Internet Explorer 9 - webpage title (document.title) not showing on print

I'm trying to get the webpage title to show up on a printed version of my website. 我正在尝试使网页标题显示在我的网站的印刷版上。 I am targeting IE9 (with Chrome Frame installed). 我的目标是IE9(已安装Chrome框架)。 I have successfully changed the title with the following JavaScript 我已使用以下JavaScript成功更改了标题

document.title = "my title";

I have confirmed this by seeing the title at the tab in IE9. 我已经通过在IE9中的标签上看到标题来确认这一点。

I'm assuming there are some security permissions set up that are messing with the page title from being printed. 我假设设置了一些安全权限,这些权限使页面标题无法打印。 I created a very small basic webpage locally that prints the webpage title correctly (changing the webpage title with the above JS), but what would prevent my more complex website from printing the document title? 我在本地创建了一个很小的基本网页,可以正确打印网页标题(使用上面的JS更改网页标题),但是什么会阻止我更复杂的网站打印文档标题呢? I've read around that some ActiveX settings could do this. 我读过一些ActiveX设置可以做到这一点。

Another thing to note is that on my complex website the Print Preview option isn't there, when it is on the local simple website. 要注意的另一件事是,在我的复杂网站上,当它在本地简单网站上时,没有“打印预览”选项。 Maybe this is related? 也许这是相关的? Any input is appreciated, thanks! 任何输入表示赞赏,谢谢!

EDIT: I did try resetting IE (which removes all data and add-ons), and to no avail. 编辑:我确实尝试重置IE(删除所有数据和加载项),但无济于事。 Here's sample code (for both the complex and local-simple site I made). 这是示例代码(适用于我创建的复杂和本地简单站点)。 Like I've said above, I have confirmed that the document.title can (and does) get changed, I'm just baffled as to why the page title isn't being printed. 就像我在上面说过的,我已经确认document.title可以(并且确实)可以更改,但我对为什么不打印页面标题感到困惑。

<script type="text/javascript">
    $(document).ready(
        $('#myDiv').on('click', function(){
            document.title = 'my custom title';
        });
    );      
</script>

UPDATE: I have still not found a solution to this, but after awhile I have determined that this is an issue with Google Chrome Frame . 更新:我仍然没有找到解决方案,但是过了一段时间,我确定这是Google Chrome浏览器内嵌框架的问题 It turns out that Google Chrome Frame enabled on a page will mess up IE's printing functionality; 事实证明,在页面上启用Google Chrome浏览器内嵌框架会破坏IE的打印功能; specifically, it will not print any page headers/footers, date, current/total pages of printed website, or URL. 具体来说,它将不会打印任何页面的页眉/页脚,日期,打印的网站的当前/总页面或URL。 When GCF is enabled on a page in IE9, Print Preview is no longer even a selection anymore - my guess is since GC handles what IE9 defines as Print and Print Preview in one screen, GCF just disables it. 在IE9中的页面上启用GCF时,“打印预览”不再是一个选择-我的猜测是,由于GC在一个屏幕上处理了IE9定义的“打印和打印预览”,因此GCF只是将其禁用。 I have added GCF as a tag on this post, and I'm not sure how to further solve my problem. 我在这篇文章中添加了GCF作为标签,但不确定如何进一步解决问题。 I can say that GCF is clearly the problem here. 我可以说,GCF显然是这里的问题。 Please message me if somebody else sees this and has the same problem 如果有人看到此消息并遇到相同的问题,请给我发消息

The layout of a printed page can be configured. 可以配置打印页面的布局。

The title can be removed (exactly as the page number or the source-url) 标题可以删除(恰好是页码或源URL)

There is nothing you can do against this. 您对此无能为力。

Waht you can do is a CSS-resource for printing, that will show a special headlind (not title), that is only visible if printed. 您可以做的是用于打印的CSS资源,它将显示一个特殊的标题(不是标题),只有在打印时才可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM