473,320 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Floating Menu

I'm working with the cookie-cutter code located here:

http://www.jtricks.com/javascript/na.../floating.html

Very helpful script, BTW!

I'm trying to modify it, though, so that the menu will scroll relative
to a parent DIV instead of the main window. So, I have something like
this (simplified so that you can copy it to your viewer and see the
problem):

<br><br><br><br><br>
<table height="1000">
<tr valign="top">
<td>&nbsp;</td>
<td>
<div id="primary" style="position: relative">
<div id="floatdiv" style="
position: relative;
top: 0px; left: 0px;
width: 135px; height: 50px; border: 2px solid #000000">
Menu
</div>
</div>
</td>
</tr>
</table>

<script type="text/javascript">
// copy from jtricks above
</script>

You can see that the physical location of "primary" is 110px from the
top of the window. It's not positioned there through CSS, though; that
just happens to be where it falls in the design because of elements on
the page above it. In the sample, I gave a bunch of <br>, but on my
live page there's a logo, navigation, etc.

My problem is that when "floatdiv" moves down, it consistently stays
110px from the top of the window. Meaning, if you scroll down two or
three folds, you'll see 110px of white above the word "Menu," when I
really want it to be more like 10px. When the page initially loads
before you scroll down, the position is perfect; I just want it to not
remember to be 110px down when you scroll.

Or, I guess it's more accurate to say that I don't want the menu to
start moving until I've scrolled down by around 100px.

Any ideas on how to modify the code so that when I scroll down,
"floatdiv" will be 10px or so from the top instead of 110? I tried
modifying the "targetY" variable to 110, then to 0, then to -110, and
it doesn't seem to change anything.

TIA,

Jason
Jul 12 '08 #1
4 2446
Jason Carlton wrote:
I'm working with the cookie-cutter code located here:

http://www.jtricks.com/javascript/na.../floating.html

Very helpful script, BTW!
If it is as helpful as your failed attempt at writing HTML below ...

I won't visit the site just to add to your hits anyway.
[...]
<br><br><br><br><br>
<table height="1000">
The `table' element has no `height' attribute.

<http://validator.w3.org/>
[...]
In the sample, I gave a bunch of <br>, but on my
live page there's a logo, navigation, etc.
Why do you provide pointless examples?
My problem is that when "floatdiv" moves down, it consistently stays
110px from the top of the window. Meaning, if you scroll down two or
three folds, you'll see 110px of white above the word "Menu," when I
really want it to be more like 10px. When the page initially loads
before you scroll down, the position is perfect; I just want it to not
remember to be 110px down when you scroll.

Or, I guess it's more accurate to say that I don't want the menu to
start moving until I've scrolled down by around 100px.

Any ideas on how to modify the code so that when I scroll down,
"floatdiv" will be 10px or so from the top instead of 110? I tried
modifying the "targetY" variable to 110, then to 0, then to -110, and
it doesn't seem to change anything.
You have a rather long-winded way to tell everyone you do not know what you
are doing. I suggest you learn HTML and CSS before you attempt to script
Web user agents. Try googling "position fixed".
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jul 13 '08 #2
If it is as helpful as your failed attempt at writing HTML below ...
>
I won't visit the site just to add to your hits anyway.
I didn't give a site for you to visit, genius.

The `table' element has no `height' attribute.

<http://validator.w3.org/>
Excuse the crap out of me, I didn't know that I had to post validated
code as a sample. I would have assumed that a genius such as yourself
would be able to work with it.

In case you're too stupid...

<table>
<tr height="10000">

How's that, baby? Do you still need a pacifier?

Why do you provide pointless examples?
Just because you're too stupid to understand doesn't make it
pointless.

You have a rather long-winded way to tell everyone you do not know what you
are doing. *I suggest you learn HTML and CSS before you attempt to script
Web user agents. *Try googling "position fixed".
Interestingly, you have a rather long-winded way to tell everyone that
you're a dick, but still don't know how to answer the question. Why
waste everyone's time if you can't contribute?

::sigh::

Thanks for being a douche. You've reminded me of why anyone of value
has stopped using the newsgroups.
Jul 13 '08 #3
Jason Carlton wrote:
[...]
>You have a rather long-winded way to tell everyone you do not know what you
are doing. I suggest you learn HTML and CSS before you attempt to script
Web user agents. Try googling "position fixed".

Interestingly, you have a rather long-winded way to tell everyone that
you're a dick, but still don't know how to answer the question. Why
waste everyone's time if you can't contribute?

::sigh::

Thanks for being a douche. You've reminded me of why anyone of value
has stopped using the newsgroups.
That must be the people from whom Googlodytes like you have learned proper
language and Web development. FOAD.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jul 14 '08 #4
On Jul 14, 11:06*am, Jason Carlton <jwcarl...@gmail.comwrote:
If it is as helpful as your failed attempt at writing HTML below ...
I won't visit the site just to add to your hits anyway.

I didn't give a site for you to visit, genius.
The `table' element has no `height' attribute.
<http://validator.w3.org/>

Excuse the crap out of me, I didn't know that I had to post validated
code as a sample. I would have assumed that a genius such as yourself
would be able to work with it.

In case you're too stupid...

<table>
<tr height="10000">

How's that, baby? Do you still need a pacifier?
Why do you provide pointless examples?

Just because you're too stupid to understand doesn't make it
pointless.
You have a rather long-winded way to tell everyone you do not know whatyou
are doing. *I suggest you learn HTML and CSS before you attempt to script
Web user agents. *Try googling "position fixed".

Interestingly, you have a rather long-winded way to tell everyone that
you're a dick, but still don't know how to answer the question. Why
waste everyone's time if you can't contribute?

::sigh::

Thanks for being a douche. You've reminded me of why anyone of value
has stopped using the newsgroups.
Actually, the fix is simple - only one extra line of code is needed in
the floating menu script.

On line 70, the script determines what the new desired Y coordinate
(position from the top of the page) will be for the div to move to.
All you need to do is check this value after it has been calculated -
it is lower the 150 (or whatever), set it to 150.

So, immediately before "if (floatingMenu.targetY < 0)" on line 76 add
the following code:

floatingMenu.shiftY = ( floatingMenu.shiftY < 150 ) ? 150 :
floatingMenu.shiftY;

Incidentally, since you now now that floatingMenu.shiftY will always
be greater than zero, you could remove the next code block.

And presto - it works!

Best of luck,
Hamish
Jul 14 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: TyBreaker | last post by:
What is the best way to create a menu bar like the Office menu bar ie one that can dock to the four corners of the screen? Is it a standard windows form or is it some other more specialised...
0
by: pat.maher | last post by:
I have an application that is not an mdi but rather made up of multiple sdi forms. I am trying to keep a single set of menus and toobars that change contents depending on the form that has...
3
by: bdbeames | last post by:
I have a menu on the right side of my page and a flash object in the center. When a certain option in the menu is select a sub menu pops and floats left. The problem is, depending on the browser...
2
by: Dariusz Tomoń | last post by:
Hi, I have got JS at: http://www.euroadres.pl/b2b.aspx for floating menu - it activates when scrolling down. Under IE it works ok but under FF it doesn't float and what's more it covers a part...
1
by: elusified | last post by:
Hi guys, i am now doin this website that required a floating menu. the problem is how do i restrict the floating menu to prevent it from goin out of the navigation area when the window is minimize?...
2
by: yela | last post by:
I am working in a floting menu for a website, I found this cool script, it works great, but I need to limit the movement of the menu to a table area, right now it goes up and down through the whole...
1
Parul Bagadia
by: Parul Bagadia | last post by:
I just wrote a code for myself to clear certain things........... When i made this program to execute in turbo c++ it didnt..... it showed following error. I have pasted the output after code is...
0
by: colin | last post by:
Hi, I have an IDE style editor based on the WeifenLuo.WinFormsUI.Docking code, wich I must say seems realy good. Im trying to activate drop down menus and such from various special command...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.