473,405 Members | 2,279 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,405 software developers and data experts.

Dynamic Menu for all browsers

hi people,

My problem is that I need to build a dynamic menu (preferably that
works in all the browsers) that appears when I mouseover a certain
link.

The problem is that I have to declare the menu content in the same
part of the page where the menu goes (BODY). The content of the page
is generated dynamically so I can't put the menu content it on the
headers.
I worked around this problem with this:

this goes in the <head>:

<script type="text/javascript">
/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsBy TagName("span");
//DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}

</script>

example of the html text in the pages:

<span id="masterdiv"><span class="menutitle"
onMouseOver="SwitchMenu('sub1')" onMouseout="window.status=''; return
true">Menu1</span>
<span class="submenu" id="sub1"> menu text<br> menu text<br> menu
text<br></span></span><p>

<span id="masterdiv"><span class="menutitle"
onMouseOver="SwitchMenu('sub2')" onMouseout="window.status=''; return
true">Menu2</span>
<span class="submenu" id="sub1"> menu text<br> menu text<br> menu
text<br></span></span>

The problem is that it looks awful... and it breaks the page...
any ideas?
cordially,
stromboli
Jul 23 '05 #1
4 5168
Once upon a time *Stromboli* wrote:
hi people,

My problem is that I need to build a dynamic menu (preferably that
works in all the browsers) that appears when I mouseover a certain
link.

The problem is that I have to declare the menu content in the same
part of the page where the menu goes (BODY). The content of the page
is generated dynamically so I can't put the menu content it on the
headers.
I worked around this problem with this:

this goes in the <head>:

<script type="text/javascript">
/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsBy TagName("span");
//DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}

</script>

example of the html text in the pages:

<span id="masterdiv"><span class="menutitle"
onMouseOver="SwitchMenu('sub1')" onMouseout="window.status=''; return
true">Menu1</span>
<span class="submenu" id="sub1"> menu text<br> menu text<br> menu
text<br></span></span><p>

<span id="masterdiv"><span class="menutitle"
onMouseOver="SwitchMenu('sub2')" onMouseout="window.status=''; return
true">Menu2</span>
<span class="submenu" id="sub1"> menu text<br> menu text<br> menu
text<br></span></span>

The problem is that it looks awful... and it breaks the page...
any ideas?
cordially,
stromboli


Try an external .js file with the script, with
<script type="text/javascript" src="menu.js"></script>
linking to the file. And leave also out the <script
type="text/javascript"> and </script> from the file.

--
/Arne

Jul 23 '05 #2
st********@hotpop.com (Stromboli) wrote:
My problem is that I need to build a dynamic menu
You don't "need" to do that at all.
(preferably that works in all the browsers)
Not possible, all techniques able to do that (css , javascript, java,
flash etc.) are optional for a www UA. Btw, all are of topic for this
group.
example of the html text in the pages:

<span id="masterdiv"><span class="menutitle"
onMouseOver="SwitchMenu('sub1')" onMouseout="window.status=''; return
true">Menu1</span>
Oh dear. Wrong markup, and only accessible with javascript enabled.
The problem is that it looks awful... and it breaks the page...


Plenty of examples available of dynamic menus that are based upon
properly marked up links, Google is your friend.

--
Spartanicus
Jul 23 '05 #3
Stromboli wrote:
My problem is that I need to build a dynamic menu (preferably that
works in all the browsers) that appears when I mouseover a certain
link.


Use the one at http://devedge.netscape.com/

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Jul 23 '05 #4
Stromboli wrote:

My problem is that I need to build a dynamic menu (preferably that
works in all the browsers) that appears when I mouseover a certain
link.
What do you mean by "all browsers"? Text to speech? Netscape 1? The
Googlebot?

I can speak for myself: I would make a basic distinction between
browsers understand document.getElementById, and those that don't
(which I'd exclude, in order to write standardized JS/DOM).

The problem is that I have to declare the menu content in the same
part of the page where the menu goes (BODY). The content of the page
is generated dynamically so I can't put the menu content it on the
headers.
I worked around this problem with this:

The problem is that it looks awful... and it breaks the page...
any ideas?
cordially,
stromboli


Maybe you can use an external JS, and call a parametrized function?
Like buildMenu(4, 2) or something. You could store the navigation logic
in the JS, the link structure in the HTML (for non-JS clients) and the
underlying data in XML or an SQL-Database.

--
Google Blogoscoped
http://blog.outer-court.com
Jul 23 '05 #5

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

Similar topics

1
by: Macamba | last post by:
Hi all, I am currently developing a website for a voluntary organisation. It is my first step in website development. The dynamic menu I developed has some bugs, which I addressed in another...
2
by: Martin Doyle | last post by:
Ok, I'm building a JS-based limitless-sublevel dynamic menu and am making it cross browser as well - 3 packs of aspirin so far and counting ;) I'm having a weird rendering problem using Opera...
26
by: Thomas Mlynarczyk | last post by:
Hi, Could some kind person using Mac or Linux (or others) please take a look at http://www.mlynarczyk-webdesign.de/tmp/menu/menu.html and tell me if the page renders as it should (screenshot...
1
by: Phil | last post by:
Supposedly, the code below should assign the correct value to the 'url' variable. But all I get is a blank 'main' Frame with apparently nowhere to go when I click on the link in the 'menu'...
2
by: LRW | last post by:
I've a page where I have two form drop-menu. I need the second menu to populate only with items based on what's selected in the 1st menu. I have "Javescript in Easy Steps" and the closest it...
1
by: paulakeijzers | last post by:
I've got a problem with asp.net i am trying to make a menu control. and have searched the web for serveral controls but they don't work correctly. I am pretty new to asp.net building. What am i...
3
by: scaredemz | last post by:
hi, so i'm creating a dynamic drop-down menu. the menu and the text show up fine in IE but only the drop-down shows in Firefox without the menu text. Below is the fxn code. help pls. function...
5
by: Seth Bourne | last post by:
I've seen the microsoft product (microsoft dynamic AX). it really impressed me cause it looks like windows form, but it is web form (run on IE). it hidden menubar, toolbar and everything on IE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.