图片居中显示 解决立即给分
使图片居中显示:代码如下 我用是ScriptX.cab控件
<%
dim wjlj
wjlj="D:/WebSite/MANAGE/DA/Upload/uploadfile/"+request.QueryString("wjlj")
%>
<html >
<head>
</OBJECT>
<object id="factory" style="display:none"
viewastext classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="/print/ScriptX.cab#Version=5,60,0,360">
</OBJECT>
<SCRIPT defer>
//用于设置打印参数
function printBase() {
factory.printing.footer = "" //页眉
factory.printing.footer = "" //页脚
factory.printing.portrait = false //true为纵向打印,false为横向打印
factory.printing.leftMargin = 3 //左页边距
factory.printing.topMargin = 0.5 //上页边距
factory.printing.rightMargin = 3 //右页边距
factory.printing.bottomMargin = 1.0 //下页边距
}
//用于调用设置打印参数的方法和显示预览界面
function printReport(){
printBase();
//window.print();
factory.printing.Preview();
}
//使界面最大化
maxWin();
function maxWin()
{
var aw = screen.availWidth;
var ah = screen.availHeight;
window.moveTo(0, 0);
window.resizeTo(aw, ah);
}
</SCRIPT>
<script language="JavaScript">
<!--
var flag=false;
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= 1000/700){
if(image.width>1000){
ImgD.width=1000;
ImgD.height=(image.height*1000)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>700){
ImgD.height=700;
ImgD.width=(image.width*700)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
}
}
//-->
</script>
</head>
<body>
<p class="NOPRINT">
<input type="button" name="cmdPRINT" id="cmdPRINT" onClick="printReport()" value="打印" class="NOPRINT">
<input type="button" onClick="window.close();" value="关闭" class="NOPRINT">
</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="centr" bordercolor="#FFFFFF">
<img src="<%=wjlj%>" width="1000" height="700" align="absmiddle" onload="javascript:DrawImage(this);">
我这样设置 在打印的时候一直是左对齐, 如何使他居中 ?我的图片很大 4080*3040
</table>
</body>
</html>