用在PHP里的JS打印函数

auto=1立即PRINT,否则timeOut毫秒后PRINT,如printPage(0,5000); function
printPage($auto=1,$timeOut=10000) { if ($auto == 1) { echo ” SCRIPT
LANGUAGE=”JavaScript” !– Begin if (window.print) { window.print(); }
else { alert(‘No printer driver in your PC’); } // End — /script n”; }
else { echo ” SCRIPT LANGUAGE=”JavaScript” !– Begin if (window.print) {
setTimeout(‘printCheck()’,’$timeOut’); } else { alert(‘No printer driver
in your PC’); } function printCheck() { agree = confirm(‘OK to print
now?’); if (agree) window.print(); } // End — /script n”; } }

<script>
function centerWindow(url,w,h){
l=(screen.width-w)/2
t=(screen.height-h)/2
window.open(url,”,’left=’+l+’,top=’+t+’,width=’+w+’,height=’+h)
}
</script>
<input type=button

onclick=”centerWindow(‘about:blank’,200,200)”>

<body>
<SCRIPT LANGUAGE=”JavaScript”>
var s =”网页可以知道区域宽:”+ document.body.clientWidth;
s+=”rn网页可知区域高:”+ document.body.clientHeight;
s += “rn网页正文全文宽:”+ document.body.scrollWidth;
s += “rn网页正文全文高:”+ document.body.scrollHeight;
s += “rn网页正文部分上:”+ window.screenTop;
s += “rn网页正文部分左:”+ window.screenLeft;
s += “rn显示器分辨率的高:”+ window.screen.height;
s += “rn荧屏分辨率的宽:”+ window.screen.width;
s +=”rn显示屏可用工作区中度:”+ window.screen.availHeight;
s +=”rn荧屏可用职业区宽度:”+ window.screen.availWidth;
alert(s);

复制代码 代码如下:

</SCRIPT>

<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
function redirectPage() {
/*var url640x480 =

var url800x600 = “index1.asp”;
var url1024x768 = “index2.asp”;
/*if ((screen.width == 640) && (screen.height == 480))
window.location.href= url640x480;*/
if (screen.width <= 800 )
window.location.href= url800x600;
else if ((screen.width >= 1024) )
window.location.href= url1024x768;
}
// End –>
</script>

这段代码是基于不一样的显示屏显示区别的页面

上边是传递那几个参数的

复制代码 代码如下:

<script language=JavaScript>
document.write(“<a href=’WebStat/index.asp’>”);
document.write(“<img
src=’WebStat/count.asp?Referer=<%=refer%>
&Width=”+escape(screen.width)+”&Height=”+escape(screen.height)+
“‘ border=0 width=1 height=1>”);
document.write(“</a>”);
</script>

复制代…

在做页面时,客户必要,分歧的分辨率,弹出窗口的地点不一样,作者想是还是不是先得到荧屏宽度,然后付值给变量,再在onclick中装置参数

复制代码 代码如下:

<script>
alert(screen.width+”*”+screen.height)
</script>

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图