Title text in image maps

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Chris Burnley

Title text in image maps

Post by Chris Burnley » Tue Oct 08, 2002 4:12 am

I don't know if this has been mentioned before but, for mozilla, the image map seems to need a title attribute rather than an alt tag for displaying tooltips.

I'd like to propose the following patch:

--- entity/ChartEntity.java~ Tue Oct 8 11:50:11 2002
+++ entity/ChartEntity.java Tue Oct 8 13:03:03 2002
@@ -197,8 +197,10 @@
+ " COORDS=\""+getShapeCoords() + "\"";
if (this.urlText == null ? false : !this.urlText.equals(""))
tag += " href=\"" + this.urlText + "\"";
- if (this.toolTipText == null ? false : !this.toolTipText.equals(""))
+ if (this.toolTipText == null ? false : !this.toolTipText.equals("")){
tag += " alt=\"" + this.toolTipText + "\"";
+ tag += " title=\"" + this.toolTipText + "\"";
+ }
tag += ">";
return tag;
}

Richard Atkinson

Re: Title text in image maps

Post by Richard Atkinson » Tue Oct 08, 2002 8:42 am

Chris,

No, it hasn't been brought up before but I did notice the title attribute when looking at the HTML 4.0 spec on another issue yesterday. I had missed it before because it is listed under the common attributes.

Your fix works well, however I would go a bit further and suggest that the title attribute can replace the alt attribute to define the tooltip text, as the title attribute seems to work in both Internet Explorer and Mozilla. I haven't tested Netscape and Opera yet but will do this evening and post the results.

Providing both attributes could significantly increase the size of the HTML for large image maps and the title attribute seems to do the job nicely on its own. It also provides more cross-browser compatibility than the alt tag which only works in Internet Explorer.

If no-one has any objections I will commit the change to CVS in a couple of days.

Regards,
Richard...

Richard Atkinson

Re: Title text in image maps

Post by Richard Atkinson » Tue Oct 08, 2002 8:03 pm

I've tested against Opera 6.05 and Netscape 4.6 and the title attribute works in Opera but not in Netscape. I don't have an install of the latest Netscape version to test on.

On the basis that using the title attribute works on Internet Explorer, Mozilla and Opera, I have committed the change to use the title attribute instead of the alt attribute in com.jrefinery.chart.entity.ChartEntity.

- tag += " alt=\"" + this.toolTipText + "\"";
+ tag += " title=\"" + this.toolTipText + "\"";

As far as I am aware the change should not impact anyone's code because the new attribute seems to be supported by a wider range of browsers. If anyone finds a problem with any other browser versions, please let me know.

The modification will go out as a part of version 0.9.4 which rumour has it David will be putting together in the next couple of weeks.

Thanks for the patch Chris, much appreciated.

Regards,
Richard...

Chris Burnley

Re: Title text in image maps

Post by Chris Burnley » Wed Oct 09, 2002 2:34 am

Great.

I should have mentioned that I did some testing and it seems that Netscape 4.x doesn't use the alt tag at all for image maps anyway ( as far as I can tell ).

Chris

Locked