打开文档.Windows,打印它并关闭它(不'不关闭)
Open document.windows, print it and close it (doesn't close)
这是我得到的函数-感谢stackoverflow中的搜索选项和我的一些修改-
<script type="text/javascript">
function imprimirElemento(elem)
{
abrirElemento($(elem).html());
}
function abrirElemento(data)
{
var style = '<style type="text/css">.titulosLightBox {border-bottom: 1px dotted #D1D1D1;color: #333333;font-size: 20px;font-weight: normal;line-height: 18px;margin-bottom: 15px;padding-bottom: 10px;}'+'strong{width:100%;font-weight:bold;}'+'</style>';
var termsAndConditions = window.open('', 'tos', 'height=400,width=600');
termsAndConditions.document.write('<html><head><title>Politica de Privacidad</title>');
termsAndConditions.document.write(style);
termsAndConditions.document.write('</head><body >');
termsAndConditions.document.write(data);
termsAndConditions.document.write('</body></html>');
termsAndConditions.document.close();
termsAndConditions.print();
termsAndConditions.document.close(); /*This seems not to work*/
return true;
}
</script>
它工作得很好,它打开了窗口;文件正在打印样式和所有东西,但窗口没有关闭,
知道为什么吗?
thanks a lot
Try
termsAndConditions.close();
最后一行是错误的,因为您已经关闭了文档对象。尝试termsAndConditions.close()
相关文章:
- 使用promise和mongoose对文档进行排序
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- Ajax请求文档就绪会导致jquery加载缓慢
- MongoDB (php) - 以数组而不是多个属性的形式返回文档属性
- 谷歌文档表面引擎
- 来自文档或下一个静态父级的事件委派
- 如何将childNodes用于XML文档
- 文档就绪提供了错误的选择器高度
- 将当前用户的 ID 推送到 meteorjs 中集合/文档的内部数组
- 未捕获的语法错误:无法在“文档”上执行“查询选择器”
- BrowserId登录请求在文档加载时被调用
- 从Javascript和Php变量创建Html模板文档
- 如何通过谷歌应用程序脚本从谷歌文档中的位置确定命名范围
- 在jquery文档准备好之前加载Modernizr
- 如何判断何时将dom节点添加到文档中
- 无法获取文档.GetElementById工作正常
- 为什么是文档.旧版应用程序中的DOM-object.properties为null
- 有没有一种方法可以在没有文档或jQuery的情况下使用javascript解码html实体
- Windows Phone WebBrowser:获取文档高度的正确方法
- 打开文档.Windows,打印它并关闭它(不'不关闭)