2011-03-08 78 views
1

JavaScript函數window.print在IE7和8中工作,但在IE9中沒有工作。有人可以幫助解決這個問題嗎?window.print在IE9中不工作

+3

嘿Suganya,歡迎來到SO。你能說得更具描述性嗎?你能展示一段不起作用的代碼嗎?除非您讓他們瞭解您的問題並縮小範圍,否則這裏沒有人可以幫助您。 – 2011-03-08 08:15:26

+0

那麼有誰找到了修復程序呢?我仍然有這個問題。 – 2012-05-10 13:05:45

回答

1

嘗試下面的代碼:

onClick="javascript:window.print(); 
return false; 
+0

爲什麼你有沒有循環的[標籤](https://developer.mozilla.org/en/JavaScript/Reference/Statements/label)? – Quentin 2011-05-25 13:30:04

+0

這個答案可能沒有幫助。這意味着你必須點擊某些內容,而Suganya不一定需要onClick行爲。此外,不推薦混合JavaScript和html。有關詳細信息,請參閱http://code.google.com/edu/submissions/html-css-javascript/#introduction。 – 2011-05-25 17:16:34

0

試試這個:

onclick="window.print(delay*1000); return false;" 
0

你需要做的幾件事情。

  1. 添加在

  2. 正確關閉文件:mywindow.document.close();

  3. 做重點的documnet:mywindow.focus();

  4. 然後寫打印代碼:mywindow.print();

exp:

var mywindow = window.open('', 'My Print Data', 'width=850,scrollbars=yes'); 
mywindow.document.write('<html><head><title>Print Page</title><meta http- equiv="X-UA-Compatible" content="IE8"/>'); 
.......... 
......... 
......... 
........... 
mywindow.document.write('</div></body></html>'); 
mywindow.document.close(); 
mywindow.focus(); 
mywindow.print(); 
+0

這個答案不是很清楚...點1)在一個添加一個,,,什麼? – abarisone 2015-03-18 13:31:52