korkus2000

msg:1472009 | 12:37 pm on Jun 11, 2003 (gmt 0) |
Excellent script and post BlobFisk!
|
BlobFisk

msg:1472010 | 1:12 pm on Jun 11, 2003 (gmt 0) |
Thanks korkus! Just one edit (which I only just spotted). In the init() function there are two lines of code which are not needed (remnants from an older project): screenSize = document.body.clientWidth + 18; and screenSize = window.innerWidth; |
| You can remove these without any effect on the script. If anyone has any questions or enhancements - fire away!
|
tedster

msg:1472011 | 4:12 am on Jun 12, 2003 (gmt 0) |
Not a question, but a comment. I like the fact that you have a timer function. Some dHTML menu systems can be almost scary when a mouseout generates an instantaneous reaction, with stuff popping up and vanishing in a very uncomfortable and distracting fashion. It's a nice touch, and it doesn't need to be set very high to greatly improve the feel of the menu.
|
BlobFisk

msg:1472012 | 10:54 am on Jun 12, 2003 (gmt 0) |
That was something that was quite important for me to build in day 1, as I feel there is quite a usability issue with menu's that vanish the millisecond you mouse out of them - if it's an accident you have to start from scratch! The one thing I look forward to is universal support of onmouseover and onmouseout events on the <div> tag. It means that you start and stop the timer only once per drop down - rather than sometimes having to put multiple instances of it in for each link element in your drop down navigation layer.
|
jfred1979

msg:1472013 | 7:15 pm on Jun 18, 2003 (gmt 0) |
I'm trying to implement the drop down menu outlined in this thread, and I'm having problems positioning the div that will contain the menu items without it taking up space in the body of my document. My site uses a centered design so when I use absolute positioning the horizontal position of the menu is off. Am I not understand the basic way this menu system should be implemented?
|
Reflection

msg:1472014 | 11:02 pm on Jun 18, 2003 (gmt 0) |
jfred If you are using a centered design, the 'centered' position will vary by user's screen resolution etc. so your absolutely positioned menu's will not line up with your centered design. You will either have to work out some relative positioning or change to a left-aligned design.
|
jfred1979

msg:1472015 | 2:04 am on Jun 19, 2003 (gmt 0) |
I understand the reason for the problem, but using relative positioning causes the div to occupy screen space even when it's not visible. Is there way around this? I really like this script because it seems to be the cleanest coded solution for menus I can find, I prefer to use it rather than a few others I've tried....
|
BlobFisk

msg:1472016 | 10:24 am on Jun 19, 2003 (gmt 0) |
That's a very interesting question. Firstly, give your menu <div>'s a very high z-index. Secondly, depending on where you are putting the <div>'s, don't forget that nested layers use the 0,0 position of the parent element. So, if you have a central layer, nesting a menu <div> inside this, with an absolute position of top: 10 and left: 50 will mean that the menu div is 10 pixels below the top of the parent div and 50 pixels to the right of the left point. Do you think that this may be a solution to the problem that you've outlined?
|
jfred1979

msg:1472017 | 2:31 pm on Jun 19, 2003 (gmt 0) |
That's what I'm doing right now BlobFisk, but when I use absolute positioning it's basing the 0 coordinates on the browser window, not the parent div. I thought it was only with relative positioning that the parent layer was used.
|
BlobFisk

msg:1472018 | 8:34 pm on Jun 19, 2003 (gmt 0) |
Hmmm - that's strange jfred1979. My tests show that nested div inherit their 0,0 points from the parent div. Try this CSS: <style type="text/css"> #mainDiv { top: 50px; left:100px; position: absolute; width: 300px; height: 200px; border: 1px solid #000; background: #fff; color: #000; } #nestDiv { top: 10px; left:20px; position: absolute; width: 50px; height: 50px; border: 1px solid #000; background: #fcc; color: #000; } </style>
|
| And this HTML: <div id="mainDiv"> <div id="nestDiv"> Test </div> </div>
|
| Let me know what results you get.
|
jfred1979

msg:1472019 | 8:47 pm on Jun 19, 2003 (gmt 0) |
Well, you are absolutely right. The nested div uses the parent for it's base coordinates. I'll have to go back and check my code, must have made an error somewhere. What a revelation! This changes a lot of issues I was having trying to convert this originally table based site to CSS.
|
BlobFisk

msg:1472020 | 9:31 pm on Jun 19, 2003 (gmt 0) |
Oh yeah! You'll find that CSS is full of revelations!
|
Reflection

msg:1472021 | 10:43 pm on Jun 19, 2003 (gmt 0) |
BlobFisk: I have a question about the browser sniffing portion of your code. By testing for 'document.all' before 'document.getElementById' the variable 'what' will always be set to ie4 if you are using Internet Explorer. Later you say "We evaluate the layerRef variable value (document.all for old IE browsers...". My question is are you intentionally setting all IE browsers to not be 'dom1'? Thanks, Great script btw.
|
jfred1979

msg:1472022 | 10:48 pm on Jun 19, 2003 (gmt 0) |
One more question now that I have the basic function of the script working, does a new showlayer and hidelayer function need to be created for each layer? I get the feeling I don't need to, but if not what replaces the layerName variable in those functions? Sorry for the basic question but I'm just learning Javascript and I haven't done any sort of "real" programing for years.....
|
Reflection

msg:1472023 | 11:10 pm on Jun 19, 2003 (gmt 0) |
| does a new showlayer and hidelayer function need to be created for each layer? I get the feeling I don't need to, but if not what replaces the layerName variable in those functions? |
| The layerName is the ID of menu div that you want to show/hide. So when you call the show function in your onMouseover you pass the function the ID of the menu you want to show. Then in the hideAll() function you need to call the hideLayer for each menu you have. funtion hideAll{ hideLayer('menu ID'); hideLayer('next menu ID')... and so on.
|
BlobFisk

msg:1472024 | 10:15 am on Jun 20, 2003 (gmt 0) |
Hey Reflection, Excellent point - you are quite correct. The way the conditional in init() is set out at the moment does mean that all IE4 and above and Opera will have what as "ie4". To correct this, just move the DOM1 conditional to the top. Thanks for the catch! jfred1979: As Reflection says, you only need one function for showing the layers and one for hiding the layers. They layer that you wish to show or hide is fed into that function. So, to show a layer called aboutMenu: showLayer('aboutMenu');
|
jfred1979

msg:1472025 | 5:10 pm on Jun 24, 2003 (gmt 0) |
Okay I think I have the whole thing sorted out now. This makes my code much cleaner than using the Dreamweaver produced menus as I was doing before....
|
BlobFisk

msg:1472026 | 5:17 pm on Jun 24, 2003 (gmt 0) |
Glad you got it working jfred1979!
|
Reflection

msg:1472027 | 5:46 pm on Jun 24, 2003 (gmt 0) |
Couple things I just noticed... #1 The visibleVar is never actually used in the hide and show functions. #2 Shouldnt you also require a 'hideVar', since NN4 visibitity properties are 'show' and 'hide', rather than 'visible' and 'hidden'? I havent had a chance to test this with NN4 so I could be wrong :).
|
BlobFisk

msg:1472028 | 5:57 pm on Jun 24, 2003 (gmt 0) |
Hey Reflection, Quite right - you can remove the visibleVar and the screenSize variable declerations. I apologise, these are artifacts from the devlopment lifecycle that I forgot to remove. Thanks for the heads up. The script does work in NN4.x (tested in 4.74), which does understand visible and hidden.
|
captainbri

msg:1472029 | 7:05 pm on Jul 24, 2003 (gmt 0) |
hi, im having soem trouble making this work in ns 4.xx any help would be appreciated! here is my code <snip> <snip> thanks [edited by: korkus2000 at 7:07 pm (utc) on July 24, 2003] [edit reason] TOS #21 [/edit]
|
BlobFisk

msg:1472030 | 9:02 am on Jul 25, 2003 (gmt 0) |
Hey captainbri, If you could describe what is (or is not) happening, then we can try and get to the root of the problem.
|
carramba

msg:1472031 | 6:11 pm on Aug 13, 2003 (gmt 0) |
It seams like very nice nav meniu, but I have another question: I have tryed how can I use this code to show/hide layer on click? I the poin is that I have php meniu and I only want to swith layer on "extra meniu" also when user clicks on link layer changes when hi/she click agai u se onother layer.. problem is that when it click for second layer it show OK, but when user click on firs (visited) layer again it dont shows.. hoppe I make sense..
|
BlobFisk

msg:1472032 | 8:50 am on Aug 14, 2003 (gmt 0) |
Instead of using onMouseOver, use onClick to display the layer. The function works exactly the same way. You will run into problems if you need to have the same link also hide the layer again. TO achieve this, you will need to write a function that detects the current visibility of the layer, and toggle it to visible/hide, depending.
|
carramba

msg:1472033 | 11:52 am on Aug 14, 2003 (gmt 0) |
Its sound so simple when you say it.. but I have tryed.. but its to difficult to me.. ( or I just make it difficulf..) what arguments and function should I use do achiev it?
|
BlobFisk

msg:1472034 | 12:42 pm on Aug 14, 2003 (gmt 0) |
In pseudocode: function toggleVisibility(layerName) { if layerName visibility == visible { then run the hideLayer function; } else { then run the showLayer function; } }
That should do it.
|
carramba

msg:1472035 | 2:28 pm on Aug 14, 2003 (gmt 0) |
yeah.. I am in real war with you script :) is this correct that I use: href="#" after <a> and did I understand that first script reads function showLayer(layer1), then I call that function in function togglevisibility? if yes should I have the function for each layer? ( I think yes, but please correct my) P.S. I am quaite new in javascript so forgive me for my "stupid" questions..
|
BlobFisk

msg:1472036 | 10:21 am on Aug 15, 2003 (gmt 0) |
is this correct that I use: href="#" after <a> |
| I don't quite understand this, I'm afraid! | and did I understand that first script reads function showLayer(layer1), then I call that function in function togglevisibility?if yes should I have the function for each layer? ( I think yes, but please correct my) |
| You're right that you call the showLayer function in the toggle function - but you do not need to create a seperate function for each layer. All the functions take in a variable, which is the layer ID. By doing this, it allows us to use the function over and over again through the document.
|
carramba

msg:1472037 | 11:12 am on Aug 15, 2003 (gmt 0) |
| I don't quite understand this, I'm afraid! |
| I mean when the link calls script shoud I have link like this: | <a href="#" onClick="hideAll();showLayer('first')">show hidden 1</a> |
| or | <a href="javascipt:;" onclick="hideAll();showLayer('second')"> show hidden 2</a> </div> |
| and I have evean more thought ... then I run show/hide functions in togle script how does it reads which layer to show/hide if it calls the global show/hide functions? one more: do I call it by: | function hideLayer(layerName); |
| btw. Iam begining to se the light in this dark code tunnel.. :)
|
|