目前看到最方便的方法,感謝前人的教學,文章連結:
https://www.wfublog.com/2014/12/traditional-simplified-chinese-auto-switch.html
目前看到最方便的方法,感謝前人的教學,文章連結:
https://www.wfublog.com/2014/12/traditional-simplified-chinese-auto-switch.html
| <script type="text/javascript"> function checkserAgent(){ var userAgentInfo=navigator.userAgent; var userAgentKeywords=new Array(“Android", “iPhone" ,"SymbianOS", “Windows Phone", “iPad", “iPod", “MQQBrowser"); var flag=false; if(userAgentInfo.indexOf(“Windows NT")==-1){ flag=true; } return flag; } if(checkserAgent()){ document.location.href="http://cynet.tw/mobile/"; } </script> |
<input id="btnPrint" type="button" value="列印成績" onclick="printScreen(printlist)"/>
<div id="printlist">
<table style="width: 750px">
<tr>
<td>
欄位一
</td>
<td style="width: 150px">
欄位二</td>
</tr>
<tr>
<td colspan="2">
可以把GirdView放在這裡來列印
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td colspan="2">
表尾</td>
</tr>
</table>
</div>
function printScreen(printlist)
{
var value = printlist.innerHTML;
var printPage = window.open("","printPage","");
printPage.document.open();
printPage.document.write("<HTML><head></head><BODY onload='window.print();window.close()'>");
printPage.document.write("<PRE>");
printPage.document.write(value);
printPage.document.write("</PRE>");
printPage.document.close("</BODY></HTML>");
}
| 列印 Html 網頁時的強制換頁方式 |
| 透過 CSS 的 Pagebreak 來處理列印 Html 強制換頁。 |
| 在標籤後換頁 { page-break-after: always } 在標籤前換頁 { page-break-before: always } |
| <P style="page-break-after:always"> </P> |
<INPUT TYPE="button" value="整頁列印" onclick="print()"><div id="block">
<P><img id=”ruten” name=”ruten” SRC=”http://www.ruten.com.tw/imgs/2008/logo.gif”></P>
</div>
<input type=”button” value=”部分列印” onclick=”printScreen(block)”>function printScreen(block){
var value = block.innerHTML;
var printPage = window.open(”",”printPage”,”");
printPage.document.open();
printPage.document.write(”<HTML><head></head><BODY onload=’window.print();window.close()’>”);
printPage.document.write(”<PRE>”);
printPage.document.write(value);
printPage.document.write(”</PRE>”);
printPage.document.close(”</BODY></HTML>”);
}<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>
<INPUT TYPE=”button” value=”整頁預覽” onclick=”javascript:wb.execwb(7,1)”><div id="block">
<P><img id=”ruten” name=”ruten” SRC=”http://www.ruten.com.tw/imgs/2008/logo.gif”></P></div>
<input type=”button” value=”區塊預覽” onclick=”previewScreen(block)”>function previewScreen(block){
var value = block.innerHTML;
var printPage = window.open(”",”printPage”,”");
printPage.document.open();
printPage.document.write(”<OBJECT classid=’CLSID:8856F961-340A-11D0-A96B-00C04FD705A2′ height=0 id=wc name=wc width=0></OBJECT>”);
printPage.document.write(”<HTML><head></head><BODY onload=’javascript:wc.execwb(7,1);window.close()’>”);
printPage.document.write(”<PRE>”);
printPage.document.write(value);
printPage.document.write(”</PRE>”);
printPage.document.close(”</BODY></HTML>”);
}