keeping a menubar on top of the site

M

Martin Hesselbach

Hi folks,

I was trying to "pin" a menubar to the top of a site.
It should allways stay on its absolute position.
Especially when the user scrolls the page...

I did like this:

<div id="object1" style="position:absolute; visibility:left:50px;
top:50px"> MENU </div>

called from a timer:

document.object1.style.top=50;
OR
window.document.object1.style.top=50;
OR
document.object1.top=50;
OR
window.document.object1.top=50;

none of them worked...
now what?


THX!
M. Hesselbach

PS: It's ok if it runs in firefox, no need for IE support...
 
D

David Dorward

Martin said:
I was trying to "pin" a menubar to the top of a site.
It should allways stay on its absolute position.
Especially when the user scrolls the page...

Is is it that hard for the user to scroll back up?
<div id="object1" style="position:absolute; visibility:left:50px;
top:50px"> MENU </div>

visibility what?
called from a timer:

document.object1.style.top=50;

That should be document.getElementById('object1') and "50px", but won't do
any good since you are just setting it to what it is anyway.

You probably want position: fixed, not absolute. There wouldn't be any need
for JavaScript at all, but IE doesn't support fixed. Google will reveal
JavaScript to fake position: fixed support in Internet Explorer.
 
M

Martin Hesselbach

David said:
Martin Hesselbach wrote:




Is is it that hard for the user to scroll back up?




visibility what?




That should be document.getElementById('object1') and "50px", but won't do
any good since you are just setting it to what it is anyway.

You probably want position: fixed, not absolute. There wouldn't be any need
for JavaScript at all, but IE doesn't support fixed. Google will reveal
JavaScript to fake position: fixed support in Internet Explorer.

Still not working....

this is just for trying to move a DIV:
<html><body>
<div id="object1" style="position:absolute; left:50px; top:50px">
<a href="javascript:document.getElementById('object1').style.top=60px">
Movable Menu</a>
</div></body></html>

is doing nothing in IE or Firefox...
won't work without the ".style" part neither...

this shouldnt be that hart, ey?

thx again

M. Hesselbach
 
M

Martin Hesselbach

David said:
Martin Hesselbach wrote:




So you're ignoring everything I said about not using absolute and JavaScript
for this then?




1: http://jibbering.com/faq/#FAQ4_24

2: Strings, like 60px, must be surrounded by quote marks in JavaScript.


thx

works like this now:

function pinScroll() {
pindelay = setTimeout('pinScroll()',50);
document.getElementById('chordsbar').style.top=(window.pageYOffset+3)+'px';

}

<div id='chordsbar' style='position:absolute'>


its acctually for a lyrics and chords/tabs displaying page...
it scrolls trough the song and the displayed chords you have to play
stay...


M. Hesselbach
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top