gpt4 book ai didi

javascript - 尝试使用 Ajax 进行 window.open,window.print 不起作用(IE9)

转载 作者:行者123 更新时间:2023-11-28 02:30:41 24 4
gpt4 key购买 nike

我正在尝试打开新窗口并使用 javascript 和 jquery-1.8.3 发送表单数据。

在 Bernhard 的帮助下,我成功调用了一个包含打印页面的新窗口。

(非常感谢伯恩哈德。window.open and sending form data not working)

但是,window.print() 函数在 IE9 中不起作用! (FF、Chorme 做得很好)

我刷新了页面,然后 IE9 调用 window.print()

这是源代码。

<a href="#" onclick="printPage()">Print this</a>

<script type="text/javascript" src="/common/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">

function printPage(){

$.post('/common/print.jsp', {view:$("#ctn").html()}).success(function(response){
var oWindow = window.open('', "printWindow", "width=700px,height=800px");
oWindow.document.write(response);
oWindow.print(); // I added this line. But IE9 not working.
});
}
</script>

有什么我错过的吗?

最佳答案

试试这个:

    $.post('/common/print.jsp', {view:$("#ctn").html()}).success(function(response){
var oWindow = window.open('', "printWindow", "width=700px,height=800px");
oWindow.document.write(response);
oWindow.document.close();
oWindow.focus();
oWindow.print(); // I added this line. But IE9 not working.
});

检查这个:

使用 HTTP header 在 Internet Explorer 8 及更高版本中强制使用标准 View

您还可以使用元标记强制使用标准模式。 X-UA-Compatible 元标记 告诉 Internet Explorer 要使用或模拟哪种 View 模式。

通过设置此元标记,您可以告诉 IE 使用标准模式,即使 DOCTYPE 上方有注释或 XML 声明也是如此。确定哪个版本的 Internet Explorer 可以最好地查看该内容页面,然后设置元标记来定义该版本。

IE 7:

<meta http-equiv="X-UA-Compatible" value="IE=7">

IE 8:

<meta http-equiv="X-UA-Compatible" value="IE=8">

IE 9:

<meta http-equiv="X-UA-Compatible" value="IE=9">

If a customer comes to a page with a view mode higher than it supports (e.g. an IE 7 browser viewing a page asking for IE8 view mode), it will ignore the tag and render the page the the mode it would have without the tag.

更多信息请参见:http://webdesign.about.com/od/internetexplorer/qt/force-compatibility-view-in-ie.htm

关于javascript - 尝试使用 Ajax 进行 window.open,window.print 不起作用(IE9),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14229098/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com