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:17

Javascript error on Floating "Back to Top" button


Poster: InfernoCruiser
Dated: Monday January 16 2006 - 20:32:58 GMT

Just curious if anyone can see anything obvious (I see the error in IE, but not FF).

http://www.webstudiohelp.net/index.html
- look to the left side border for the graphic.

I'm getting an error on pages where I've called a simple menu (really just an image of an arrow being used).

Here's all that's being used for the arrow:

with(milonic=new menuname("Main Menu")){
style=menuStyle;
top=229;
alwaysvisible=1;
followscroll=1;
aI("image=Icons/top.jpg;url=#top;");
}

drawMenus();

That .js file is being called for in several pages - all seem to generate the error in IE.

Thanks


Poster: vikenk
Dated: Monday January 16 2006 - 20:51:38 GMT

Hi,

I'm not sure exactly what the error says - it just says "error on page". HOwever, the Back to Top arrow *does work*. But why are the error messages coming? A couple of things jump out to me. They may or may not make a difference:

1) I'm not sure you've implemented the script correcty in your table. Try moving the following code out of the table and with the other menu files, or just place the contents of the js file in the table.
Code:
        <SCRIPT type="text/javascript" src="embedded_WS_Help_Main.js"></SCRIPT>
        <SCRIPT type="text/javascript" src="menu_data_Top_Button.js"></SCRIPT>


2) In your menu_data_Top_Button.js file you have this:
Code:
with(milonic=new menuname("Main Menu")){
style=menuStyle;
top=229;
alwaysvisible=1;
followscroll=1;
aI("image=Icons/top.jpg;url=#top;");
}


drawMenus();


The first line is style=menuStyle; but you have no "menuStyle" defined. The error could be that the JS is looking for "menuStyle" and not finding it. Try taking it out.

Hope this helps. Let us know how it works out.

Viken K.


Poster: InfernoCruiser
Dated: Monday January 16 2006 - 21:17:35 GMT

The error (should have posted it before - sorry) is:

Line: 21
Char: 6759
Error: Object required
Code: 0
URL: http://www.webstudiohelp.net/

I tried moving those files outside of the table - didn't make a difference.

There is a seperate file for styles (menu_styles.js) - this was suggested as the way to do it (single file for all menus).

I was wondering if maybe it was the way I have the top of page function set up (url=#top).

Removing the menustyle= portion results in the graphic disappearing.


Poster: vikenk
Dated: Monday January 16 2006 - 22:03:22 GMT

Hmmm...my next suggestion would then be to start removing the Menu Script files, one at a time, until you narrow down exactly which file is causing your problem. Remove the js file reference in the html. If the problem doesn't go away, then put the file back in and remove the next file. Once you narrow down the file, maybe we can find something in it.

Viken K.


Poster: vikenk
Dated: Monday January 16 2006 - 22:18:41 GMT

Another thought:

You said the error is in "Line: 21, Char: 6759". According to my editor, only the "mmenudom.js" file has that many characters in one line. The source files have all the whitespace taken out, so all the code in in one long line.

The milonic_src.js file has only ~5700 characters (accirding to my editor), and the mmenudom.js file has over 30,000 characters, all in one line. So I'll make an educated guess that the error is occuring in the mmenudom.js file.

Just as a test, try replacing the file and see what happens. Maybe it has somehow become corrupted? I had this happen to me to the tooltips.js file once. It became corrupted and I replaced it and my problems went away.

Make sure you replace it with the same version. Better yet, update tot he newest version.


Poster: InfernoCruiser
Dated: Monday January 16 2006 - 23:22:16 GMT

Thanks for taking the time to check this.

In case it's needed, the version currently loaded to the site is 5.738

Replaced the sources files with the latest (5.739) and I'm testing locally (haven't uploaded the new files yet). It's still showing the error, although it has changed slightly:

The error is now:
Line: 21
Char: 6776
Error: Object required
Code: 0

Without that 'back to top' button, there is no error (as in the pages without it). :|

It must be something simple in how it's being called....


Poster: vikenk
Dated: Tuesday January 17 2006 - 3:17:11 GMT

Well, I'm stumped :>(

I've been at it for some time and can't get it. I've even replaced all the menu files with a newly downloaded set. I added your styles and the error still happens.

I copied and pasted all your code and js files: still happens. I removed all your code and left nothing but the menu: still happens. One curious thing though: I've scoured all your code and can't find a reference to <a name="top">.

I ran a search for <a name, <a id, <a name=top, and top. I didn't come across one reference to an anchor named TOP. Yet, it still works?!? Anyway, even after I added <a name="top"></a>, the error still occurs.

BTW, are you using MIcrosoft FrontPage? When I use IE, all I see is "Error on Page" in the status bar. When I open it in Frontpage, I see the full error as you described.

Sorry. I'm out of ideas right now.

Viken K.


Poster: Ruth
Dated: Tuesday January 17 2006 - 3:30:51 GMT

Hi,

I just used your image on the downloaded menu page and I had no problem, no error shows. One thing I can't find on your page is the anchor

Code:
<a name="top"></a>
where is that? Or whatever you named it.

By the way, if the main menu is in the table, relative postioned, you should put the embed file back in that table, but the other should be up with the milonic files, the one for the top since it's not relatively positioned.

Ruth


Poster: InfernoCruiser
Dated: Tuesday January 17 2006 - 11:06:41 GMT

Thanks, Viken.

No, not using Frontpage.
In IE, I just double click on the error icon and a small window opens displaying the information.

And Hi, Ruth.

Are you using IE? I see the error in IE6. And just a note - the error only shows when you mouse-over the arrow graphic.

(Any testing noted below is locally).

I haven't placed <A name ="top"></a> references anywhere, since placing a URL of "#" will take you to the top of the page you're on. I just added the "top" text to indicate that it's going to the top of the page. Also removed "top", but that made no difference.

I did add an anchor (middle of page for testing), and it did work properly, but the error was still generated.

I've also tried changing it to 'URL=index.html' - and while it does work on the index page (as you'd expect - the page refreshes), the error is still there.

Thanks for the heads-up on menu placement. I'll move the top of page menu out of the table on the next round. I did try that locally, too, but it didn't make any difference.

Thanks for the input. ;)


Poster: Ruth
Dated: Tuesday January 17 2006 - 15:04:02 GMT

::whew::

Ok, I got it. Don't ask me what the problem is, I don't know, but I know how to fix it. Also, you've got a couple of other errors.

1. you have the embedded menu named as Main Menu and also the button named as Main Menu, change the name, maybe call it button.

2. You are not positioning the main menu relatively in the table, so move the call for the file up after the program files, just like normal.

3. I'm not sure why you have split everything out unless it's just for some organizational thing to have the styles in a different file, but you could put all of the files back into one file, unless you are going to put the main into a table at some date.

Now to fixing the problem. Add this to your styles file, right below the ending } of the menuStyle code

Code:
buttonStyle=new copyOf(menuStyle);
buttonStyle.onitalic=0;


Then go to your button data file and change the name of the menu from main to something else, and change the style to style=buttonStyle;

I have no idea what the problem is but that fixes it. For some reason that onitalic=1; is causing the error in that button menu.

Ruth


Poster: vikenk
Dated: Tuesday January 17 2006 - 21:32:19 GMT

Wow! Good work Ruth! I wouldn't have thought to look there.


Poster: Ruth
Dated: Tuesday January 17 2006 - 21:41:18 GMT

Well, I would never have thought to look there, either. With limited knowledge on things and not being able to think what might cause a problem I tend to start going line by line. Usually I open the original downloaded menu_data.js file and then start copy and paste line by line :)

Ruth


Poster: InfernoCruiser
Dated: Tuesday January 17 2006 - 21:48:25 GMT

Hi Ruth,

I'm usually pretty good at figuring things out, but I doubt that I would have found the italic setting as being the culprit! Nice job :D

I've changed the button menu name to 'Top Menu'.

I tested moving the main and secondary menus out of the table they were in and placing a 'position="relative" ' item in the Styles Menu. While the menus themselves seem to work properly (with the exception of a slight drop, which should be adjustable in the menu itself), I did notice that items in submenus don't shift inwards when the browser window is narrowed. Instead, the text wraps and the link outline expands downwards.

I'm going to guess that I'd need to re-write the menus so that the submenus would be placed inside a table of their own to stop that from happening.

The menus were broken down like that to allow the secondary 'main' menus to load only on the pages that they belong. It also does make finding things a little easier, as there are a lot of links on the site.

As far as the Styles Menu, it was another member here that suggested that it was the way it should be done.

Because I promote the use of this menu every chance I get (and have licensed it for a few sites myself), I'd like to try to get it set up how it should be. From that point, I can modify a very brief tutorial page I made for using it with the site-building software I use. The menu, as it is essentially set up now, was more or less approved by Milonic as an okay way to go a few months ago.


Poster: kevin3442
Dated: Tuesday January 17 2006 - 23:05:05 GMT

Just a quick comment...

First, yes Ruth... nice work indeed!

Second, the error actually does happen in Firefox as well, but you need to open the JavaScript Console to see it (under the Tools menu). It's a useful tool in tracking down js errors, because it usually gives better info in its messages than IE does.

Last, for the curious, the reason using the onitalic property causes the error seems to be because, in this particular case, there is no text in the menu item to italicize on mouseover (i.e., try turning onitalic back on, then add a text value to the aI() string... no error on mouseover). Not a big deal if the menu is composed only of images, as in this case (i.e., you wouldn't need to italicize an item with no text). But it could be a pain if you have a menu made of some image items and some text. This looks like an issue that needs to be addressed in a future release. Nice job uncovering it!

Cheers,

Kevin


Poster: InfernoCruiser
Dated: Tuesday January 17 2006 - 23:32:38 GMT

Glad that I could be of some type of help here :roll:

Now, I'm off to see what other types of grief I can cause elsewhere! :}


Poster: Ruth
Dated: Wednesday January 18 2006 - 0:28:51 GMT

Hi,

I think there is a misunderstanding here. My comment on the menu files was because you had it set with a top= and left= positioning, i.e. absolute positioning, and since there are no submenus, all of that menu are items with links, then there is no reason to put the call for the menu file into that table cell.

If you want a menu in the table cell, you mentioned something about different menus, then either call for the file or the main menu itself in the table cell. You would take out the top=; left= positioning and put in position="relative"; That doesnt go in the styles file, it goes in the file with the main menu, in the same place you now have the top and left position coded. This is only assuming you want it in the table cell. It can be there, even if it doesn't have submenus. If it has submenus then the following applies, also.

You would put the submenus in a separate file and that would be called at the top with the program files. That let's them be 'read' first before the main menu and that is necessary when you put the menu in a table cell.

Hope that made sense, I think I confused myself :?

Ruth