Javascript| Skills//calculation content width and height <script language= "JavaScript" >
function test (obj)
{
var range = Obj.createtextrange ();
Alert ("Content area width:" + range.boundingwidth
+ "px\r\n content area Height:" + range.boundingheight + "px");
}
</SCRIPT>
<BODY>
<textarea id= "txt" height= ">sdf</textarea><input type=" button "value=" Compute content width "onclick=" Test (TXT) ">
</BODY>
//modeless prompt box function Modelessalert (MSG)
{
Window.showmodelessdialog ("Javascript:alert" ("+escape" (MSG) + "\"); Window.close (); "," "," STATUS:NO;RESIZABLE:NO; help:no;dialogheight:height:30px;dialogheight:40px; ");
}
//Screen keys
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<noscript><meta http-equiv= "Refresh" content= "0;url=about:noscript" ></noscript>
<title> screen right mouse button, CTRL + N, SHIFT+F10, Alt+f4, F11, F5 refresh, backspace key </title>
<body>
<script language= "Javascript" ><!--
Screen the right mouse button, CTRL + N, SHIFT+F10, F11, F5 refresh, backspace key
Author:meizz (Plum blossom rain) 2002-6-18
function Document.oncontextmenu () {event.returnvalue=false;} Mask right mouse button
function Window.onhelp () {return false}//Shield F1 Help
function Document.onkeydown ()
{
if ((Window.event.altKey) &&
((window.event.keycode==37) | | Shielding ALT + Direction key ←
(window.event.keycode==39))) Shielding Alt + Direction key →
{
Alert ("You are not allowed to use ALT + arrow keys forward or back page!") ");
Event.returnvalue=false;
}
* Note: This is not really shielding ALT + arrow keys,
Because ALT + ARROW keys pop-up warning box, hold down the ALT key,
With the mouse point off the warning box, this shielding method is invalid. Later if
There is a master who has really shielded the Alt key method, please inform. */
if ((event.keycode==8) | | Mask BACKSPACE Delete key
(event.keycode==116) | | Mask F5 Refresh Key
(Event.ctrlkey && event.keycode==82)) {//ctrl + R
event.keycode=0;
Event.returnvalue=false;
}
if (event.keycode==122) {event.keycode=0;event.returnvalue=false;} Shielding F11
if (Event.ctrlkey && event.keycode==78) Event.returnvalue=false; Block CTRL + N
if (Event.shiftkey && event.keycode==121) Event.returnvalue=false; Shielding SHIFT+F10
if (Window.event.srcElement.tagName = "A" && Window.event.shiftKey)
Window.event.returnValue = false; Screen shift plus left mouse button new page open
if ((Window.event.altKey) && (window.event.keycode==115))//Shielding ALT+F4
{
Window.showmodelessdialog ("About:blank", "" "," dialogwidth:1px;dialogheight:1px ");
return false;
}
}
</script>
Screen the right mouse button, CTRL + N, SHIFT+F10, Alt+f4, F11, F5 refresh, backspace key
</body>
//Screen printing
<style>
@media print{
* {Display:none}
}
</style>
Move the layer, drag
1.<span style= ' position:absolute;width:200;height:200;background:red ' Onmousedown=mousedown (this) onmousemove= MouseMove () onmouseup=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" ondrag= Dodrag (); "onmouseover=" this.style.cursor= ' hand ' style= ' position: absolute;left=100;top=100; "onmousedown=" Domousedown (); >
<a href= "#" onclick= "return false" ></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>
Document status change
<iframe src= "a.html" id= "F" name= "F" scrolling= "no" frameborder=0 marginwidth=0 marginheight=0></iframe>
<script>
var doc=window.frames["F"].document;
function S () {
if (doc.readystate== "complete") {
Document.all.f.style.height=doc.body.scrollheight
Document.all.f.style.width=doc.body.scrollwidth
}
}
Doc.onreadystatechange=s
</script>