Single quote break "Status" text

Please note that official support for this menu version has now ceased. There are still plenty of users, though, and the forum is still running. Some of our long-time users may be able to help you out.
Post Reply
blimey
Advanced
Advanced
Posts: 17
Joined: Mon Jun 10, 2002 1:16 pm

Single quote break "Status" text

Post by blimey »

When a single quote is inserted into the Status for a menu item, an error occurs immediately when the page is loaded. This breaks for me using IE6, but doesn't break with Mozilla 1.0.

This is easy to reproduce, get the standard menu.zip and in menu_array.js change

,"Home","http://www.dynamicdrive.com",,"Back to the home page",1 // "Description Text", "URL", "Alternate URL", "Status", "Separator Bar"

to:

,"Home","http://www.dynamicdrive.com",,"Back to the 'home page'",1 // "Description Text", "URL", "Alternate URL", "Status", "Separator Bar"

Error is:

Line: 20
Error: Expected ')'
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Don't you have to escape the silly thing... :?:

\'home page\'

Think that's it (working from home today - brain is still in bed :!: )
John
blimey
Advanced
Advanced
Posts: 17
Joined: Mon Jun 10, 2002 1:16 pm

Post by blimey »

I believe the string literal in my example is syntactically correct as JavaScript.

Using the escape sequence as suggested to construct the menu_array would give the same results because it would represent the same string. As it happens, I did post both cases before making my original post.

FYI: the use of the escape sequence \' is optional in this case, since I have used double quotes to enclose the string literal. If they were required, then this URL would also error: javascript:alert("O'Reilly");

I strongly believe this is just a case which the Milonic menu just can't handle currently. My current work-around is simply to have no status text for these exceptional cases - this is clearly not ideal.

I look forward to this being acknowleged as a bug with mmenu.js and ultimately being fixed!
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Try double escaping the apostrophe.

Code: Select all

,"Home","http://www.dynamicdrive.com",,"Back to the \\'home page\\'",1 // "Description Text", "URL", "Alternate URL", "Status", "Separator Bar" 
blimey
Advanced
Advanced
Posts: 17
Joined: Mon Jun 10, 2002 1:16 pm

Post by blimey »

I can understand how that would compensate for the bug in mmenu.js, but I would rather see this fixed in mmenu.js than use this work around. While what you've suggested may solve the problem, it seems like a kludge to me and just doesn't seem "right" long term.

Should I assume that you don't intend to fix this bug and that I must use this work around (for ever)? Or alternatively, should I assume that you will fix it at a later date, and that upgrading to a new mmenu.js might make my code incompatible?
Post Reply