Forum Moderators: open

Message Too Old, No Replies

Drop Down Menus

most efficient way?

         

fashezee

8:44 pm on Sep 17, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am working on a site that requires drop down menus.

What is the most reliable and efficient way to create drop down menus?
A few options that I am considering are:

- layers (hide/show) when over button
- javascript

I am sure that there are more methods, so what are they? and what are their
pros & cons?

Filipe

9:33 pm on Sep 17, 2002 (gmt 0)

10+ Year Member



"Requires" drop down menus? Heheh.

Well, Javascript menus use hidden layers. This combination of Javascript and HTML is called DHTML, I believe. I have a functional script that you can use, Sticky me with your e-mail address if you want it. I'll send it with instructions on how to use it.

austtr

10:46 pm on Sep 17, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check the dynamicdrive site. There is a selection of menu types including drop downs. I have used one of their offerings and it works fine.

Susanne

7:48 am on Sep 18, 2002 (gmt 0)

10+ Year Member



Good idea to use layers (show/hide) because spiders are able to index the text in your links. (Well, at least Google does.)I was afraid to use it in the beginning because it is hidden content but several knowledgeable people in a forum assured me that there was little or no risk.

The site in question was launched in November and I have had no problems with it. It has been doing extremely well in Google and other engines and I really can't ask for better ranking. I had a hard time solving the problem of making the layers "hide" the way I wanted them to (being a newbie!) but eventually managed to find a solution. If you have trouble, just sticky mail me and I'll send you the URL of the site I am talking about and I can explain how I did it.

BlobFisk

9:54 am on Sep 18, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The menu systems from dynamicdrive are nice, but they have their limitations.

Firstly, the code is hugely bloated so that it is easy for the user to customise the script to their requirements. Secondly, they are difficult to modify without trawling through the code and figuring our whats going on. Finally, the rarely support putting images into the drop-down layer.

With a reasonably quick learning curve you can write your own script to do this, that uses layers on the page in which you can put whatever you like.

I started out using the dynamicdrive layers, ran into the problems above and eventually wrote my own, which does what I want it to do and can be customised completely for each new project. I haven't looked back since. Sticky Mail me if you'd like it... but nothing beats doing your own for complete understanding of whats happening!

moonbiter

2:18 pm on Sep 18, 2002 (gmt 0)

10+ Year Member



Brainjar [brainjar.com] has a nice tutorial on the subject.

Robert Charlton

5:53 am on Sep 22, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I'm not building sites with drop down menus, but I do need to optimize them. I've been assuming... perhaps incorrectly... that if the menu doesn't drop down when javascript is off, then it's not going to work with the spiders.

Susanne's comments suggest that menus using layers are search friendly. In general, is there any easy way to tell easily what menus will work for search? If I look at the code, what do I look for? I'm not a javascript expert, and not great with CSS either.

tedster

6:16 am on Sep 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you look at the HTML, and the links are straight <a href=...>, they aren't inside some <script> tags or after a "javascript:" attribute in an anchor - then you've got a spiderable link.

In many DHTML menus javascript needs to be active to switch the div's visibility onmouseover. But in the HTML code, a spider just sees something like:

<div class="foo">
<a href="bar.htm" onmouseover="switchon()" onmouseout="switchoff">foobar</a>
</div>

That's safe.

Susanne

7:35 am on Sep 22, 2002 (gmt 0)

10+ Year Member



Well, in my case it is like this:
I have one layer with a little image on which I put the mouseover show and hide commands. Then I have ANOTHER layer which is the actual layer that "shows and hides" upon mouseover of the FIRST layer. This second layer is plain and simple without any spider unfriendly coding. Just a bunch of text links, that's all.
The whole site in question is designed 100% in layers to take advantage of being able to push valuable content high in the html while putting images and other less important stuff further down. So maybe (I'm not sure) the only way to separate links from javascript in rollovers like this is to use layers. I do not use CSS for any of the layers on the site, only for basic text styles.

Robert Charlton

7:36 am on Sep 22, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



So then would something like this be OK?

<div align="center"><a href="sample.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('sample','','top_nav/pulldowns/pac_sample_ro.gif',1)"><img name="sample" border="0" src="top_nav/pulldowns/pac_sample.gif" width="115" height="17"></a></div>

(I've changed the file names, but I think what's going on should be clear).

tedster

7:55 am on Sep 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Susanne:
Actually, what are often called "layers" are divs in the HTML, right? Their positioning is determined by CSS and their visibility is also a CSS rule which is then switched by javascript onmouseover.

Robert:
That's an image rollover, and it's very easily spiderable.

A suggestion - align="center" is a deprecated attribute. Inline you can use style="text-align:center" or you can give the div a class (or ID) and define the text-align in the rules for the class/ID. Those rules may be either in an external stylesheet or in the document's HEAD section.

Susanne

9:46 am on Sep 22, 2002 (gmt 0)

10+ Year Member



Yes Tedster, you can choose between div, span, layer and ilayer. And yes again, of course I use CSS, duh! What I thought (but didn't write!) was that I don't use EXTERNAL style sheets for the layers. I do use external CSS but only for basic font stuff. I am still pretty green and was even greener when I launched the site in question. But I am sure the style I have applied to the layers can be put in the external CSS.
However I was a little afraid that search engines like Google wouldn't like having style hidden away in external files that control hidden layers. Whatever the Googlebots are able to do and see, I wanted all the coding regarding the layers to be absolutely clear and visible to spiders. And I also heard several warnings in various forums about layers and how engines might judge them if they are hidden. So I'm keepin' my fingers crossed permanently that hidden layers which make up a simple dropdown menu won't be banned.

tedster

2:36 pm on Sep 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Isn't it funny how css feels somehow like cheating, even when it's not? Look how many threads ask about whether it's OK to style H tags.

When I first started using divs that switch visibility I had a similar concern. But that kind of code was already in use around the web, and today you see it a lot more today than you did then!

I quickly felt that there could never be some knee-jerk automatic ban just because a page contains a visibility:hidden; rule.

Then I realized that I already had been running a kind of test. The first site where I ever used external stylesheets had a div that began with a negative position - off the screen. DHTML slid it on screen.

The site had been doing well, and a log check showed no bot asking for the .css file at any rate.

Now, I know that a negative position is not the same as visibility:hidden -- but just considering it helped me understand how very unlikely some kind of universal penalty would be -- it would catch so more non-spam" than spam.

And writing an automated algo to separate the chaff from the wheat? That seemed to be an even bigger challenge. The SE's would need to run the javascript to see if the negative position or hidden visibility was part of a DHTML effect or part of a spam scheme.

Can you imagine Seach Engines running unknown JavaScript automatically, script which might very well be malicious? I highly doubted that. And even if they did - how would they be testing the results?

So, my conclusion was that suspected CSS spamming would need to be a hand-check from the SE, and not an automated script of some kind. My innocent DHTML had nothing to fear from a hand check whatsoever, so I went blithely forward. And I have had no problems to date.

However, I began to shy away from such tricky pages for other reasons - mostly usability/stickyness. Log analysis showed me that these menus were getting a relatively poor report card.

Robert Charlton

4:21 pm on Sep 22, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



tedster - Many thanks. As for the code, it's not mine... just something I pulled from the source of one of many sites I'm seeing these days that use pull downs, require javascript to load, have default flash on startup, etc. I'm having to sort out why they're not getting search traffic. In the case of this site, most of the "text" is graphic, but I wanted to rule out the menus as part of the problem.