Javascript 打印脚本在 IE 中不起作用
问候!
我是一个努力学习 html 和 javascript 的菜鸟 - 慢慢地。我正在尝试打印 SimpleModal 提供的 DIV。页面位于:
www.planetsarsfield.com
此“打印”功能位于底部的配方框中。在 FF 中一切都很好,但在 IE8 中根本不起作用。我肯定做错了什么,但我无法发现它。
有什么想法吗?
干杯, 泰 ++++++++++++++++++++++++++++++++++++++++++++++++++++
<script type="text/javascript">
function PrintElem(elem)
{
Popup($(elem).html());
}
function Popup(data)
{
var mywindow = window.open('', 'basic-modal-content', 'height=400,width=600');
mywindow.document.write('<html><head><title>on the grill... latest recipe</title>');
mywindow.document.write('<link href="PATH/print.css" rel="stylesheet" type="text/css" />')
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.document.close();
mywindow.print();
return true;
}
</script>
Greets!
I'm a noob struggling to learn html and javascript - getting there slowly. I'm trying to print a DIV served up by SimpleModal. The page is at:
www.planetsarsfield.com
This "Print" function is in the recipe box at the bottom. Everything works great in FF, but it doesn't work at all in IE8. I must be doing something fundamentally wrong but I can't spot it.
Any ideas?
Cheers,
TY
++++++++++++++++++++++++++++++++++++++++++++++++
<script type="text/javascript">
function PrintElem(elem)
{
Popup($(elem).html());
}
function Popup(data)
{
var mywindow = window.open('', 'basic-modal-content', 'height=400,width=600');
mywindow.document.write('<html><head><title>on the grill... latest recipe</title>');
mywindow.document.write('<link href="PATH/print.css" rel="stylesheet" type="text/css" />')
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.document.close();
mywindow.print();
return true;
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你使用的窗口名称让 IE 感到难过。请尝试使用“BasicModalContent”。 (“window.open”的第二个参数就是我所说的。)
The window name you're using makes IE sad. Try "BasicModalContent" instead. (The second parameter to "window.open" is what I'm talking about.)
这是函数定义页面上的一个链接,其他人在其中报告了“标题中的破折号”问题。看来波蒂是对的。
http://msdn.microsoft.com/ en-us/library/ms536651%28VS.85%29.aspx#6
Here's a link at the function's definition page where someone else reported the 'dash in title' problem. Looks like Pointy's right.
http://msdn.microsoft.com/en-us/library/ms536651%28VS.85%29.aspx#6