Forum Moderators: open

Message Too Old, No Replies

Strange Script?!?

         

mindless247

9:38 pm on Mar 17, 2004 (gmt 0)



I found this script the other day on a site.. was wondering if anyone could explain what exactly it's doing?

Thanks alot!

<script>

var showmenu=1

if (document.layers) {
document.captureEvents(Event.ONDBLCLICK);
}
document.ondblclick=dblclick;

if (document.layers){
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;

function handlerMM(e){
x = (document.layers)? e.pageX : event.clientX
y = (document.layers)? e.pageY : event.clientY
}

function dblclick() {
if (document.all && showmenu==1) {
document.all.printpic.style.posLeft=x
document.all.printpic.style.posLeft=x
document.all.printpic.style.posTop=y
}
if (document.layers && showmenu==1) {
document.printpic.left=x
document.printpic.left=x
document.printpic.top=y
}
if (document.all && showmenu!=1) {
document.all.printpic.style.posLeft=x-10000
}
if (document.layers && showmenu!=1) {
document.printpic.left=x-10000
}
showmenu=showmenu*-1
}
</script>

Alternative Future

9:46 pm on Mar 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello and Welcome to WebmasterWorld mindless247,

Looks to me as it is capturing the mouse events (double-clicks) of the visitor to the site, getting the x&y co-ordinates and showing the menu relative to that mouse event.

If I had not been half asleep I might have been able to turn it into pseudo code for you...

HTH,

-George

Rambo Tribble

1:14 am on Mar 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to note also that this script appears to have been written for version 4 IE (though it will run on later versions) and Netscape (later versions won't run this script). The script does not use the current DOM standard for addressing a document's elements.