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 ')'
Single quote break "Status" text
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!
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!
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"
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?
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?