Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:51

JavaScript error in gpos() from call to popup()


Poster: JMM
Dated: Monday December 29 2003 - 22:44:37 GMT

I had my site setup and working fine with the menu, whatever version I downloaded in early to mid November. Yesterday I downloaded the latest version of the menu to see if it would correct a problem that I ran into (which it didn't -- http://www.milonic.com/forum/viewtopic.php?t=3339) and today I noticed that I'm getting a JavaScript error on every page with the menu.

The error is "_gm has no properties" and it's triggered by code in mmenudom.js. The error occurs when _gm is referenced inside the gpos function when it is called at some point without being passed the proper argument. I think in this case the problem call to gpos results from a call to popup.

I get the error in both IE 6 Win and NS 7.1 Win.

My code is setup like this: when a page loads, after all of the menu related files have been loaded, I call a function that I wrote that generates a string (the name of one of the menus) and calls the popup function, passing the menu name. That's working properly, the popup function is being passed the correct menu name.

To see the problem, go to this page:
http://www.capitalandanimalhospital.com ... dical.html

You won't see the problem right away; the page will load and display a horizontal menu on the top and a vertical menu on the side. The menu on the side is displayed from a call to popup.

Click any link in the side menu and you'll see the error. However, enter the URL for any of those pages directly in the address bar of a NEW browser window (not the one you've already visited the site in) and the page will open fine with no error.

What's the deal?


Poster: Andy
Dated: Tuesday December 30 2003 - 9:56:22 GMT

Hi,

There are 2 major problems with your menu_data.js file.

The first problem is that you are using double quotes inside a single quoted string. Although this may work, it isn't supported and hasn't been tested yet so we can't say for sure that it works on all browsers.

The other problem is that you are using HTML inside the menu. Again, this will work to a degree but it's much better to let the menu do the work instead.

The menu does support rollover images and the menu should also be smart enough to space them out without the need for setting width and height etc.

So try this instead.

Code:
aI("image=/inside/images/layout/top_navbar/off/home.gif;overimage=/inside/images/layout/top_navbar/on/home.gif;url=/;showmenu=home;");


Regards
Andy


Poster: JMM
Dated: Tuesday December 30 2003 - 15:17:29 GMT

Quote:
There are 2 major problems with your menu_data.js file.

The first problem is that you are using double quotes inside a single quoted string. Although this may work, it isn't supported and hasn't been tested yet so we can't say for sure that it works on all browsers.
What do you mean, that it isn't supported by the menu system? It's par for the course in JavaScript and those double quotes are required by XHTML. And it worked fine with the menu code I downloaded in November.

Quote:
The other problem is that you are using HTML inside the menu. Again, this will work to a degree but it's much better to let the menu do the work instead.
That's what I was trying to do when I ran into a bug that had imagewidth and imageheight applied backwards, which you've now fixed (thanks).

I don't know yet if changing the menu data file in the way you describe (and the way I was already changing it) fixes the bug because I've run into another problem. How do I get my images to vertically align (in this case, top)?

Unfortunately the documentation isn't much help. I've tried the 'align', 'imagealign', and 'valign' properties (with the value of "top") in my style definition, my menu definition, and in menu items, all with no effect -- my images are being vertically aligned to the middle. See http://www.capitalandanimalhospital.com ... /test.html


Poster: Hergio
Dated: Saturday January 3 2004 - 17:45:53 GMT

Quote:
It's par for the course in JavaScript and those double quotes are required by XHTML
Actually thats not entirely correct. In javascript you MUST escape double quotes if they are contained in a string. you cannot say someString = "Hello "my" friend"; You need to escape them. And as you said, XHTML does require them, so you need to escape them in your javascript to make sure they are outputted to HTML correctly.
Quote:
How do I get my images to vertically align (in this case, top)?
Looking at your site I assuming you mean the bar along the top, that doesnt line up quite right? Seems like that could be fixed by either adjusting the position of the menu (raise it up a bit) or shrinking the size of the images you are using for the links and slightly altering the images so the words are higher. And also, you are using separator images AND menu item images, right? What if you make them the same height?


Poster: JMM
Dated: Monday January 5 2004 - 15:57:21 GMT

Hergio wrote:
Actually thats not entirely correct. In javascript you MUST escape double quotes if they are contained in a string. you cannot say someString = "Hello "my" friend"; You need to escape them.
You must escape double quotes if they are in a double quoted string, or single quotes if they are in a single quoted string, but you can have single quotes in a double quoted string or, as I had, double quotes in a single quoted string.

Quote:
Looking at your site I assuming you mean the bar along the top, that doesnt line up quite right? Seems like that could be fixed by either adjusting the position of the menu (raise it up a bit) or shrinking the size of the images you are using for the links and slightly altering the images so the words are higher. And also, you are using separator images AND menu item images, right? What if you make them the same height?
That's right, the images in the horizontal menu at the top are not correctly vertically aligned. I only need to know what menu / style / item properties to use to vertically align the images in menu items and, assuming they work, everything will be where it should be, as it was before I changed my menu data file from having embedded HTML to using the image= syntax.


Poster: Hergio
Dated: Saturday January 10 2004 - 5:16:18 GMT

Yes you are correct with the strings.

Would any of my suggestions work? As far as I know there is no way to "tweak" the pixel position of the image in the menu item (like a way to edit the image's style take to change its properties). I recommend editting the image slightly.


Poster: JMM
Dated: Monday January 12 2004 - 14:47:17 GMT

Quote:
. . . I recommend editting the image slightly.
That's far from an ideal way to accomplish the alignment. It turns out the imageposition property worked when itemheight was also used.

I'm still getting errors from the menu code though.