javascript thread: How to print an HTML page without printing the command buttons?
Thanks Gerhard,
I got the solution from WDVL. I posted it to the 'ASP Web How To' list
where I posted the question, although this list would probably have been
more appropriate. So here it is again, its really good, I suggest people
take a copy for future reference!
(With the following code, any element with the word DRAG in its id becomes
dragable)
var oDivtoMove = null;
var currentX = 0;
var currentY = 0;
document.onmousedown = pickupDiv;
document.onmousemove = moveDiv;
document.onmouseup = dropDiv;
function pickupDiv(){
oDivtoMove = event.srcElement;
while (oDivtoMove.id.indexOf("DRAG") == -1) {
oDivtoMove = oDivtoMove.parentElement;
if (oDivtoMove == null) { return }
}
oDivtoMove.style.pixelLeft = oDivtoMove.offsetLeft;
oDivtoMove.style.pixelTop = oDivtoMove.offsetTop;
currentX = (event.clientX + document.body.scrollLeft);
currentY = (event.clientY + document.body.scrollTop);
}
function moveDiv() {
if (oDivtoMove == null) { return };
var newX = (event.clientX + document.body.scrollLeft);
var newY = (event.clientY + document.body.scrollTop);
var distanceX = (newX - currentX);
var distanceY = (newY - currentY);
currentX = newX;
currentY = newY;
oDivtoMove.style.pixelLeft += distanceX;
oDivtoMove.style.pixelTop += distanceY;
event.returnValue = false;
}
function dropDiv() {
oDivtoMove = null;
}
-----Original Message-----
From: Gerhard Wentink [mailto:data@w...]
Sent: 14 June 2001 03:36
To: javascript
Subject: [javascript] RE: How to print an HTML page without printing t
he c- ommand buttons?
Alex,
I'm sorry I can't help you directly but I think you'll find what you need
here:
http://www.dansteinman.com/dynduo/en/dynlayer-mouseevents.html
Regards,
Gerhard Wentink
----- Original Message -----
From: "Alex Shiell, ITS, EC, SE" <alex.shiell@s...>
To: "javascript" <javascript@p...>
Sent: Tuesday, June 12, 2001 4:20 AM
Subject: [javascript] RE: How to print an HTML page without printing t he c-
ommand buttons?
> its easy really...
>
> <DIV ID="myDiv">
> <TABLE><TR><TD>...stuff...</TD></TR></TABLE>
> </DIV>
>
> to read in the HTML within the DIV:
>
> sHTML = document.all.myDiv.innerHTML;
>
> now sHTML contains the string
> "<TABLE><TR><TD>...stuff...</TD></TR></TABLE>", so you can manipulate it
> however
>
> then to display your new HTML
>
> document.all.myDiv.innerHTML = sHTML;
>
>
> -----Original Message-----
> From: Suzanne Lim [mailto:limsy@l...]
> Sent: 12 June 2001 09:39
> To: javascript
> Subject: [javascript] RE: How to print an HTML page without printing the
> c- ommand buttons?
>
>
> Hi Alex,
>
> Thanks for the tip on hiding the command buttons. It worked perfectly!
> As for creating HTML dynamically, where can I obtain more information on
> the innerHTML property of a DIV? Any code samples available?
>
> Regards,
> Suzanne