Mr Initial Man
04-30-2007, 12:04 AM
Below is my layout:
T = Top
M = Menu
C = Content
--L-- Javascript-triggering link
--L-- Clicked javascript-triggering link
What I want to do is to be able to click one of the triggering links and have the menus move down to that link.
+---------+
| T |
+-+-----+-+
|M| |M|
|M| |M|
|M| C |M|
| | | |
| |--L--| |
| | | |
| | C | |
| | | |
| | | |
| | | |
| |--L--| |
| | | |
| | | |
+-+-----+-+
One link clicked
+---------+
| T |
+-+-----+-+
| | | |
| | | |
| | C | |
| | | |
|M|--L--|M|
|M| |M|
|M| C |M|
| | | |
| | | |
| | | |
| |--L--| |
| | | |
| | | |
+-+-----+-+
Another link clicked
+---------+
| T |
+-+-----+-+
| | | |
| | | |
| | C | |
| | | |
| |--L--| |
| | | |
| | C | |
| | | |
| | | |
| | | |
|M|--L--|M|
|M| |M|
|M| |M|
+-+-----+-+
I have the following script.
<head>
...
<script type="text/javascript">
function findPos(obj) {
var curtop = 0;
if (obj.offsetParent) {
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curtop += obj.offsetTop
}
}
return [curtop];
}
function MenuPosition(elm,menu1)
{
var curPos = findPos(elm)
document.getElementById(menu1).style.top=curPos[1];
document.getElementById(menu1).style.left="20px";
}
</script>
...
</head>
<body>
...
<a href="javascript:MenuPosition(this,'MainMenu')" class="top">Menu</a>
...
</body>
Unfortunately, this doesn't seem to work. What am I doing wrong? As far as I know, my HTML is valid.
This is the error that I'm getting:
Error: Error in parsing value for property 'top'. Declaration dropped.
Source File: http://localhost/Pages/Tutorial/internet.shtml
Line: 0
Note: This must work in as many browsers as possible.
T = Top
M = Menu
C = Content
--L-- Javascript-triggering link
--L-- Clicked javascript-triggering link
What I want to do is to be able to click one of the triggering links and have the menus move down to that link.
+---------+
| T |
+-+-----+-+
|M| |M|
|M| |M|
|M| C |M|
| | | |
| |--L--| |
| | | |
| | C | |
| | | |
| | | |
| | | |
| |--L--| |
| | | |
| | | |
+-+-----+-+
One link clicked
+---------+
| T |
+-+-----+-+
| | | |
| | | |
| | C | |
| | | |
|M|--L--|M|
|M| |M|
|M| C |M|
| | | |
| | | |
| | | |
| |--L--| |
| | | |
| | | |
+-+-----+-+
Another link clicked
+---------+
| T |
+-+-----+-+
| | | |
| | | |
| | C | |
| | | |
| |--L--| |
| | | |
| | C | |
| | | |
| | | |
| | | |
|M|--L--|M|
|M| |M|
|M| |M|
+-+-----+-+
I have the following script.
<head>
...
<script type="text/javascript">
function findPos(obj) {
var curtop = 0;
if (obj.offsetParent) {
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curtop += obj.offsetTop
}
}
return [curtop];
}
function MenuPosition(elm,menu1)
{
var curPos = findPos(elm)
document.getElementById(menu1).style.top=curPos[1];
document.getElementById(menu1).style.left="20px";
}
</script>
...
</head>
<body>
...
<a href="javascript:MenuPosition(this,'MainMenu')" class="top">Menu</a>
...
</body>
Unfortunately, this doesn't seem to work. What am I doing wrong? As far as I know, my HTML is valid.
This is the error that I'm getting:
Error: Error in parsing value for property 'top'. Declaration dropped.
Source File: http://localhost/Pages/Tutorial/internet.shtml
Line: 0
Note: This must work in as many browsers as possible.