Welcome to the fifth part of a nine-part series that will show you how to build a browser menu. The aim of this series is to come up with a menu code that you can use with the majority, if not all, browsers without taking the particularities of a browser into consideration. We spent significant time on the previous parts on the layout; now we will get down to the code.
Functions for a Menu for All Browsers (Page 1 of 5 )
In the previous series on building a browser menu, we created code that works very well with three major browsers, covering the majority of users. That was good. In this series we will create similar code that works with more major browsers. That is a refined achievement.
We have already talked about the layout. We have to start talking about the JavaScript code. Let us begin!
The JavaScript Code
The JavaScript code in this series is easier to write and understand than that of the previous series. We will be writing six functions, as opposed to four in the previous series. However, the length of the JavaScript code in this series is less than the length of the JavaScript code in the previous series.
The four functions from the previous series are also here, playing the same roles. However, their contents are different; in particular, the react() function here is much shorter. These differences occur because the layouts are different. There is only one global variable here associated with one of the functions.