2011-08-19 122 views
0

這是我得到了 - 這要感謝在計算器搜索選項的功能和地雷打開document.windows,打印和關閉(不關閉)

<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> 

一些修改它的偉大工程,它打開的窗口;該文件正在打印樣式和一切,但窗口其未關閉,

任何想法爲什麼?

非常感謝

回答

0

最後一行是錯誤的,因爲你已經關閉文檔對象。嘗試termsAndConditions.close()

+0

我是個騙子-.- – walialu

+0

? @Walilalu當我有同樣的想法時,這不是我的錯,但我工作中的代理服務器阻止了一個快速的答案。 – reporter

2

嘗試

termsAndConditions.close();