Here's the function btnmenu that is in the JS script file. This function uses two other functions also called contained in the multifnctn.js file, inbmenu and outbmenu. The btnmenu function is called by adding the line <script>btnmenu()</script> where the menu buttons are needed.
Here's another function, dropmenu, that is in the JS script file. The dropmenu function is called by adding the line <script>dropmenu()</script> where the drop-down menu is needed.
There is one thing to be wary of when using JS to write HTML code. The delimiter characters " and ' can get very confusing. It is important that these are added correctly.
Consider this line of HTML code ...
<input type="button" value="Home" ID="bmenu1" name="B1" onClick="location.href='http://brisray.com/index.html'" onMouseOver=inbmenu("bmenu1") onMouseOut=outbmenu("bmenu1") style="background-image:url('tile079.jpg'); font-weight: bold; color: 0000FF";>
Notice that it contains both the " and ' characters to separate one value from another.
Now consider this. The JS code for writing text and HTML code to the current document is document.write("........."); or document.write('.........'); Can you see what the problem is going to be?
As I've said, the " and ' are delimiters and are used in pairs. When JS meets the first delimiter it starts looking for the second one. When it finds it, it thinks that it's met the end of a piece of code and thinks everything else is a separate piece. Whichever version of document.write we use we're going to meet the second delimiter character sooner than expected and the rest of the code will not be processed correctly.
To get around this we need to tell the JS processor to ignore one set of delimiters, and this is done using the \ character. To illustrate this here's part of the code above inside a document.write statement ...
There is no way the code above is going to work. This is because the first delimiter is '. Instead of finding the second delimiter at the last part of the code '); it is found at 'http. To tell JS to ignore this second ' delimiter place a \ in front of it. In the example above the code now becomes ...
Taking the entire piece of code that appears in the JS file above, it now becomes ...
document.write('<input type="button" value="Home" ID="bmenu1" name="B1" onClick="location.href=\'http://brisray.com/index.html\'" onMouseOver=inbmenu("bmenu1") onMouseOut=outbmenu("bmenu1") style="background-image:url(\'tile079.jpg\'); font-weight: bold; color: 0000FF";>');
To make the above code work properly, four \ characters have had to be added to the code.
Confused? Don't worry! It looks confusing, but when you've used it a few times you'll wonder what all the fuss was about.
This page created 15th July 2004
GoStats stats counter