天天看點

JavaScript與列印有關

//缃?椤墊?????妫?绱?

<meta?name="ROBOTS"?content="灞??у??>

?????朵腑灞??у?兼??浠ヤ?涓?浜?:

????灞??у?間負"all":???浠跺?琚?妫?绱??涓?椤典??炬?ュ??琚??ヨ???

????灞??у?間負"none":???浠朵?琚?妫?绱????涓?涓??ヨ?㈤〉涓????炬?ワ?

????灞??у?間負"index":???浠跺?琚?妫?绱??

????灞??у?間負"follow":??ヨ?㈤〉涓????炬?ワ?

????灞??у?間負"noindex":???浠朵?妫?绱??浣???琚??ヨ?㈤?炬?ワ?

????灞??у?間負"nofollow":?

//???闆??椤?

<p??style="page-break-after:always">page1</p>??

<p??style="page-break-after:always">page2</p>??

//璁劇疆????

<object?id="factory"?style="display:none"?viewastext

??classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"

??codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360"

></object>

<input?type=button?value=椤甸?㈣?劇疆?慰nclick="factory.printing.PageSetup()">

<input?type=button?value=???伴?瑙??慰nclick="factory.printing.Preview()">

?

<script?language=javascript>

function?window.onload()

{

???//?--?advanced?features

???factory.printing.SetMarginMeasure(2)?//?measure?margins?in?inches

???factory.printing.SetPageRange(false,?1,?3)?//?need?pages?from?1?to?3

???factory.printing.printer?=?"HP?DeskJet?870C"

???factory.printing.copies?=?2

???factory.printing.collate?=?true

???factory.printing.paperSize?=?"A4"

???factory.printing.paperSource?=?"Manual?feed"

???//?--?basic?features

???factory.printing.header?=?"灞?宸??劇ず&b灞?涓??劇ず&b灞??蟲?劇ず椤電??锛?绗?&p椤???amp;P椤?

???factory.printing.footer?=?"锛???瀹?涔?椤佃??锛?"

???factory.printing.portrait?=?false

???factory.printing.leftMargin?=?0.75

???factory.printing.topMargin?=?1.5

???factory.printing.rightMargin?=?0.75

???factory.printing.bottomMargin?=?1.5

}

function?Print(frame)?{

??factory.printing.Print(true,?frame)?//?print?with?prompt

}

</script>

<input?type=button?value="???版??椤??慰nclick="factory.printing.Print(false)">

<input?type=button?value="椤甸?㈣?劇疆"?慰nclick="factory.printing.PageSetup()">

<input?type=button?value="???伴?瑙?"?慰nclick="factory.printing.Preview()"><br>

<a?href="http://www.meadroid.com/scriptx/docs/printdoc.htm?static"??target=_blank>?蜂?浣跨?ㄦ????锛??村?淇℃??锛??矽???</a>

?

//??甯??????伴?瑙?

WebBrowser.ExecWB(1,1)???寮??

Web.ExecWB(2,1)??抽???闆?ㄦ??????IE绐??o?骞舵??寮?涓?涓??扮???B?

Web.ExecWB(4,1)?淇?瀛?缃?椤德?

Web.ExecWB(6,1)????奧?

Web.ExecWB(7,1)????伴?瑙??

Web.ExecWB(8,1)????伴〉?㈣?劇疆?

Web.ExecWB(10,1)??ョ??椤甸?㈠????

Web.ExecWB(15,1)?濂藉?????ら??锛???寰?纭?璁ぢ?

Web.ExecWB(17,1)??ㄩ???

Web.ExecWB(22,1)??鋒?奧?

Web.ExecWB(45,1)??抽??绐?浣?????绀郝?

<style?media=print>?

.Noprint{display:none;}<!--?ㄦ???峰??ㄦ???版?堕?????????伴」??-->?

.PageNext{page-break-after:?always;}<!--?у?跺??椤?->?

</style>?

<object??id="WebBrowser"??width=0??height=0??classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">????

</object>????

?

<center?class="Noprint"?>

<input?type=button?value=???奧?慰nclick=document.all.WebBrowser.ExecWB(6,1)>?

<input?type=button?value=?存?ユ???奧?慰nclick=document.all.WebBrowser.ExecWB(6,6)>?

<input?type=button?value=椤甸?㈣?劇疆?慰nclick=document.all.WebBrowser.ExecWB(8,1)>?

</p>?

<p>?<input?type=button?value=???伴?瑙??慰nclick=document.all.WebBrowser.ExecWB(7,1)>?

</center>

//?繪?????版?剁??椤電??椤佃??

<script??language="JavaScript">??

var?HKEY_Root,HKEY_Path,HKEY_Key;

HKEY_Root="HKEY_CURRENT_USER";

HKEY_Path="//Software//Microsoft//Internet?Explorer//PageSetup//";

//璁劇疆缃?椤墊???扮??椤電??椤佃??涓虹┖

function?PageSetup_Null()

{

?try

?{

?????????var?Wsh=new?ActiveXObject("WScript.Shell");

??HKEY_Key="header";

??Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");

??HKEY_Key="footer";

??Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");

?}

?catch(e){}

}

//璁劇疆缃?椤墊???扮??椤電??椤佃??涓洪?璁ゅ??

function??PageSetup_Default()

{??

?try

?{

??var?Wsh=new?ActiveXObject("WScript.Shell");

??HKEY_Key="header";

??Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b椤電??,&p/&P");

??HKEY_Key="footer";

??Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d");

?}

?catch(e){}

}

</script>

<input?type="button"?value="娓?绌洪〉??"?慰nclick=PageSetup_Null()>

<input?type="button"?value="?㈠?椤電??"?慰nclick=PageSetup_Default()>

//娴?瑙??ㄩ??璇?

function?checkBrowser()

{?

???this.ver=navigator.appVersion?

???this.dom=document.getElementById?1:0?

???this.ie6=(this.ver.indexOf("MSIE?6")>-1?&&?this.dom)?1:0;?

???this.ie5=(this.ver.indexOf("MSIE?5")>-1?&&?this.dom)?1:0;?

???this.ie4=(document.all?&&?!this.dom)?1:0;?

???this.ns5=(this.dom?&&?parseInt(this.ver)?>=?5)??1:0;?

???this.ns4=(document.layers?&&?!this.dom)?1:0;?

???this.mac=(this.ver.indexOf('Mac')?>?-1)??1:0;?

???this.ope=(navigator.userAgent.indexOf('Opera')>-1);?

???this.ie=(this.ie6?||?this.ie5?||?this.ie4)?

???this.ns=(this.ns4?||?this.ns5)?

???this.bw=(this.ie6?||?this.ie5?||?this.ie4?||?this.ns5?||?this.ns4?||?this.mac?||?this.ope)?

???this.nbw=(!this.bw)?

???return?this;

}

//璁$????瀹瑰?藉??楂?

<SCRIPT??language="javascript">??

function??test(obj)??

{??

???????var??range??=??obj.createTextRange();??

???????alert("??瀹瑰?哄?藉害:??"??+??range.boundingWidth????

?????????????????????????????????????????????????+??"px/r/n??瀹瑰?洪??搴???"??+??range.boundingHeight??+??"px");??

?????????????

}??

</SCRIPT>??

<BODY>??

<Textarea?id="txt"?height="150">sdf</textarea><INPUT??type="button"??value="璁$????瀹瑰?藉害"??onClick="test(txt)">??

</BODY>

//??妯″?????绀烘?

function?modelessAlert(Msg)

{

???window.showModelessDialog("javascript:alert(/""+escape(Msg)+"/");window.close();","","status:no;resizable:no;help:no;dialogHeight:height:30px;dialogHeight:40px;");

}

//灞??芥????

<html>

<head>

??<meta?http-equiv="Content-Type"?content="text/html;?charset=gb2312">

??<noscript><meta?http-equiv="refresh"?content="0;url=about:noscript"></noscript>

??<title>灞??介????抽????Ctrl+N??Shift+F10??Alt+F4??F11??F5?鋒?般?????奸??</title>

</head>

<body>

<script?language="Javascript"><!--

??//灞??介????抽????Ctrl+N??Shift+F10??F11??F5?鋒?般?????奸??

??//Author:?meizz(姊??遍???2002-6-18

function?document.oncontextmenu(){event.returnValue=false;}//灞??介????抽??

function?window.onhelp(){return?false}?//灞???1甯???

function?document.onkeydown()

{

??if?((window.event.altKey)&&

??????((window.event.keyCode==37)||???//灞??鉸?Alt+??瑰???????

???????(window.event.keyCode==39)))???//灞??鉸?Alt+??瑰???????

??{

?????alert("涓???浣?浣跨??LT+?瑰??????杩???????缃?椤碉?");

?????event.returnValue=false;

??}

?????

??if?((event.keyCode==8)??||?????????????????//灞??介???煎???ら??

??????(event.keyCode==116)||?????????????????//灞??鉸?F5??鋒?伴??

??????(event.ctrlKey?&&?event.keyCode==82)){?//Ctrl?+?R

?????event.keyCode=0;

?????event.returnValue=false;

?????}

??if?(event.keyCode==122){event.keyCode=0;event.returnValue=false;}??//灞???11

??if?(event.ctrlKey?&&?event.keyCode==78)?event.returnValue=false;???//灞??鉸?Ctrl+n

??if?(event.shiftKey?&&?event.keyCode==121)event.returnValue=false;??//灞??鉸?shift+F10

??if?(window.event.srcElement.tagName?==?"A"?&&?window.event.shiftKey)?

??????window.event.returnValue?=?false;?????????????//灞??鉸?shift???榧???宸????闆?涓?缃?椤?

??if?((window.event.altKey)&&(window.event.keyCode==115))?????????????//灞???lt+F4

??{

??????window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");

??????return?false;

??}

}

</script>

灞??介????抽????Ctrl+N??Shift+F10??Alt+F4??F11??F5?鋒?般?????奸??

</body>

</html>

//灞??芥????

<style>

@media print{

* {display:none}

}

</style>

//绉誨?ㄧ???懼?锛?????

1.<span?style='position:absolute;width:200;height:200;background:red'?慰nm慰used慰wn=MouseDown(this)?慰nm慰usem慰ve=MouseMove()?慰nm慰useup=MouseUp()>meizz</span>

<script?language=javascript>

var?Obj;

function?MouseDown(obj)

{

??Obj=obj;

??Obj.setCapture();

??Obj.l=event.x-Obj.style.pixelLeft;

??Obj.t=event.y-Obj.style.pixelTop;

}

function?MouseMove()

{

??if(Obj!=null)

??{

????Obj.style.left?=?event.x-Obj.l;

????Obj.style.top?=?event.y-Obj.t;

??}

}

function?MouseUp()

{

??if(Obj!=null)

??{

????Obj.releaseCapture();

????Obj=null;

??}

}

</script>

2.

<div?id="myDiv"?src="logo.gif"?慰ndrag="doDrag();"?慰nm慰use慰ver="this.style.cursor='hand'"?style="position:absolute;left=100;top=100;"?慰nm慰used慰wn="doMouseDown();">

<a?href="#"?慰nclick="return?false"><h1>wlecome</h1></a>

</div>

<script?language="JavaScript"?type="text/javascript">

var?orgMouseX;

var?orgMouseY;

var?orgObjX;

var?orgObjY;

function?doDrag()

{

var?myObject=document.all.myDiv;

var?x=event.clientX;

var?y=event.clientY;

myObject.style.left=x-(orgMouseX-orgObjX);

myObject.style.top=y-(orgMouseY-orgObjY);

?

}

function?doMouseDown()

{

orgMouseX=event.clientX;

orgMouseY=event.clientY;

orgObjX=parseInt(document.all.myDiv.style.left);

orgObjY=parseInt(document.all.myDiv.style.top);

}

</script>

繼續閱讀