Ges
03-11-2007, 12:41 PM
Hi,
Whilst working on the wizards on my site ( and help from a few friends ), we made a menu that you can drag around your web pages. It was based on some old code I got from who knows. Anyway, it now works in IE, FF and Opera. Have'nt tried it in other browsers. I am posting the code on 2 posts but simply put them in into the same file.
Here's the 1st part which actually forms the <head> section etc.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Draggable menu</title>
<style type="text/css">
<!--
.move
{
width:100%;
background-color:#000000;
border-bottom:1px solid blue;
font-size:14px;
font-family:vardana;
font-color:"#33CCAA";
text-align:center;
}
.info
{
width:100%;
background-color:#99CCFF;
border-top:1px solid blue;
font-size:13px;
font-family:vardana;
font-color:"#33CCAA";
}
<!-- SET THE START POSITION OF THE MENU HERE -->
.panel
{
width:150;
position:absolute;
border:1px solid blue;
left:10;
top:100;
font-size:13px;
font-family:vardana;
}
.panel a:visited{color:#000000;}
.panel a{text-decoration:none;color:blue}
.panel a:hover{text-decoration:none;}
#panel a.visited
{
text-decoration:none;
}
.menu
{
width:100%;
background-color:#ffccff;
font-size:13px;
font-family:vardana;
}
-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
N = (document.all) ? 0 : 1;
var ob;
var over = false;
// MOUSE DOWN
function MouseD(e)
{
if (over)
{
if (N)
{
ob = document.getElementById("panel");
X=e.layerX;
Y=e.layerY;
return false;
}
else
{
ob = document.getElementById("panel");
ob = ob.style;
X=event.offsetX;
Y=event.offsetY;
}
}
}
// MOUSE MOVE
function MouseM(e)
{
if (ob)
{
if (N)
{
ob.style.top = e.pageY-Y;
ob.style.left = e.pageX-X;
}
else
{
ob.pixelLeft = event.clientX-X + document.body.scrollLeft;
ob.pixelTop = event.clientY-Y + document.body.scrollTop;
return false;
}
}
}
// MOUSE UP
function MouseU()
{
ob = null;
}
if (N)
{
document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
}
document.onmousedown = MouseD;
document.onmousemove = MouseM;
document.onmouseup = MouseU;
//-->
</script>
</head>
Ges.
Whilst working on the wizards on my site ( and help from a few friends ), we made a menu that you can drag around your web pages. It was based on some old code I got from who knows. Anyway, it now works in IE, FF and Opera. Have'nt tried it in other browsers. I am posting the code on 2 posts but simply put them in into the same file.
Here's the 1st part which actually forms the <head> section etc.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Draggable menu</title>
<style type="text/css">
<!--
.move
{
width:100%;
background-color:#000000;
border-bottom:1px solid blue;
font-size:14px;
font-family:vardana;
font-color:"#33CCAA";
text-align:center;
}
.info
{
width:100%;
background-color:#99CCFF;
border-top:1px solid blue;
font-size:13px;
font-family:vardana;
font-color:"#33CCAA";
}
<!-- SET THE START POSITION OF THE MENU HERE -->
.panel
{
width:150;
position:absolute;
border:1px solid blue;
left:10;
top:100;
font-size:13px;
font-family:vardana;
}
.panel a:visited{color:#000000;}
.panel a{text-decoration:none;color:blue}
.panel a:hover{text-decoration:none;}
#panel a.visited
{
text-decoration:none;
}
.menu
{
width:100%;
background-color:#ffccff;
font-size:13px;
font-family:vardana;
}
-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
N = (document.all) ? 0 : 1;
var ob;
var over = false;
// MOUSE DOWN
function MouseD(e)
{
if (over)
{
if (N)
{
ob = document.getElementById("panel");
X=e.layerX;
Y=e.layerY;
return false;
}
else
{
ob = document.getElementById("panel");
ob = ob.style;
X=event.offsetX;
Y=event.offsetY;
}
}
}
// MOUSE MOVE
function MouseM(e)
{
if (ob)
{
if (N)
{
ob.style.top = e.pageY-Y;
ob.style.left = e.pageX-X;
}
else
{
ob.pixelLeft = event.clientX-X + document.body.scrollLeft;
ob.pixelTop = event.clientY-Y + document.body.scrollTop;
return false;
}
}
}
// MOUSE UP
function MouseU()
{
ob = null;
}
if (N)
{
document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
}
document.onmousedown = MouseD;
document.onmousemove = MouseM;
document.onmouseup = MouseU;
//-->
</script>
</head>
Ges.