The function theme_imagemenu_item produces invalid HTML:

1. 'onMouseOver' and 'onMouseOut' are not valid XHTML attributes: 'onmouseover' and 'onmouseout' are though (XML is case-sensitive).

2. 'name' is not a valid attribute for the 'img' element.

The first problem can easily be solved by fixing the spelling.

The second problem takes a little more work. The module uses proprietary (Microsoft) Javascript and needs to be weened off it. Luckily this is also fairly easy. Rather than using code like:

Only local images are allowed.

the module could output:

Only local images are allowed.

Perhaps even better would be to use:

Only local images are allowed.

So that existing sites that rely on the images having unique identifiers won't break, or, if they will break, can easily be fixed.

The first solution for the second problem removes the 'name' attribute-value pair, and replaces calling the named object with the 'this' object in the Javascript code.

The 'this' object is supported by all modern webbrowsers with the exception of Microsoft Internet Explorer 3.0 for Mac OS (source: Quircksmode.org). Internet Explorer 3.0 for Mac OS was replaced in 1997 by Internet Explorer 4.0 for Mac OS and can in my opinion safely be considered redundant.

The second solution to the second problem does the same, but it replaces the 'name' attribute by the 'id' attribute, which for instance modern web browsers see as a compatible target (i.e. 'mypage.html#chapter1' works as a link target regardless of whether 'chapter1' is the value of a 'name' attribute or an 'id' attribute.)

Users who do not wish to wait for the maintainers of this module to fix this problem can easily copy the theming function to their template.php (do not forget to replace 'theme' in the function name by the name of your own theme) and apply the changes I have outlined above.

CommentFileSizeAuthor
imagemenu.module.patch1.09 KBbrankoc

Comments

brankoc’s picture

Sorry, dissappearing code. Let's try that bit again.

Current, faulty code:

<img onmouseout="document.imagemenu_1.src='/sites/all/themes/MYTHEME/images/menu/leftnav1.gif'" onmouseover="document.imagemenu_1.src='/sites/all/themes/MYTHEME/images/menu/leftnav1_mo.gif'" name="imagemenu_1" title="Welkom" alt="Welkom" src="/sites/all/themes/MYTHEME/images/menu/leftnav1.gif"/>

First solution:

<img onmouseout="this.src='/sites/all/themes/MYTHEME/images/menu/leftnav1.gif'" onmouseover="this.src='/sites/all/themes/MYTHEME/images/menu/leftnav1_mo.gif'" title="Welkom" alt="Welkom" src="/sites/all/themes/MYTHEME/images/menu/leftnav1.gif" />

Second solution:

<img onmouseout="this.src='/sites/all/themes/MYTHEME/images/menu/leftnav1.gif'" onmouseover="this.src='/sites/all/themes/MYTHEME/images/menu/leftnav1_mo.gif'" id="imagemenu_1" title="Welkom" alt="Welkom" src="/sites/all/themes/MYTHEME/images/menu/leftnav1.gif" />

marcus_clements’s picture

Version: 6.x-1.0 » 6.x-1.1
Status: Active » Fixed

Fixed in latest version

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.