|
escape ampersand in tooltips |
Posted by kirsten on Jun-21-2011 19:26 |
|
Hi,
I have an ampersand in my dataset name that I use for a legend as well as for tool-tips in the image map. However I cannot seem to get this to be escaped for the tool-tip.
$sImageMap = $c->getHTMLImageMap('', '', 'href="{dsdiField0}" title="{value} {escape_html}{dataSetName} for Minute {xLabel}" alt=""');
I get loads of html warnings for each coordinate on the image map:
Warning: unescaped & which should be written as &
<area shape="poly" coords="868,142,875,152,885,152,878,142" href="minute.php?do=0&h=1-2&m=59-60" title="39 Visitors on Tue 21 Jun 2011 between hours 1 & 2 for Minute 59-60" alt="">
If I try using {escape_url} instead that does escape it but this is obviously not any good for tool-tips:
title="39 Visitors%20on%20Tue%2021%20Jun%202011%20between%20hours%201%20%26%202 for Minute 59-60"
Does escape_html not convert & to & ? If so - what am I doing wrong? And if not - is there a way round this?
Thanks |
Re: escape ampersand in tooltips |
Posted by Peter Kwan on Jun-22-2011 02:28 |
|
Hi kirsten,
Is this an actual problem (that the browser does not understand the "&"), or it is just a theorectical problem?
According to the HTML standard, there should be no unescaped "&" in any HTML attributes. The "&" must be escaped to "& a m p ;".
However, in practice, a huge number of web pages uses unescaped "&". For example, if you look at Yahoo's home page (www.yahoo.com), or Google's home page (www.google.com), you can see lots of unescaped "&" in the HTML code. So I think practically, unescaped "&" is supported by all browsers and its usage is generally accepted.
For this reason, ChartDirector does not escape the "&" character.
If your web page does not work in some browsers, would you mind to save a copy of the page (use IE Save As, and save as web archive), and also inform me of the browser brand and version that shows the problem. There is a chance the problem is not due to the unescaped "&", but to something else.
Regards
Peter Kwan |
Re: escape ampersand in tooltips |
Posted by kirsten on Jun-24-2011 17:38 |
|
Hi,
I doesn't actually cause any problems but I validate the HTML output via Tidy and it shows it up as a warning. I prefer the page to not have any warnings so I try to clean these up whenever possible. I was hoping that was possible for the graph but it appears not. Is it anything you would consider adding later?
Regards
Kirsten
Peter Kwan wrote:
Hi kirsten,
Is this an actual problem (that the browser does not understand the "&"), or it is just a theorectical problem?
According to the HTML standard, there should be no unescaped "&" in any HTML attributes. The "&" must be escaped to "& a m p ;".
However, in practice, a huge number of web pages uses unescaped "&". For example, if you look at Yahoo's home page (www.yahoo.com), or Google's home page (www.google.com), you can see lots of unescaped "&" in the HTML code. So I think practically, unescaped "&" is supported by all browsers and its usage is generally accepted.
For this reason, ChartDirector does not escape the "&" character.
If your web page does not work in some browsers, would you mind to save a copy of the page (use IE Save As, and save as web archive), and also inform me of the browser brand and version that shows the problem. There is a chance the problem is not due to the unescaped "&", but to something else.
Regards
Peter Kwan
|
Re: escape ampersand in tooltips |
Posted by Peter Kwan on Jun-25-2011 04:51 |
|
Hi kirsten,
Escaping "&" has been in our feature list for consideration for a long time.
When we orignally designed our code may years ago, we have already known that "&" should be escaped according to the standard. However, we were quite sure not escaping "&" would work, because everybody was not escaping it, but we were not so sure if escaping "&" would work in all cases. So we had chosen not to escape "&" to make sure the resulting image map work.
Having said that, I think the older browsers at that time had long been obsoleted, and the new browsers should support the standard quite well. So we may implement this in future versions of ChartDirector.
Regards
Peter Kwan |
Re: escape ampersand in tooltips |
Posted by Peter Kwan on Jun-25-2011 04:55 |
|
Hi kirsten,
Escaping "&" has been in our feature list for consideration for a long time.
When we orignally designed our code may years ago, we have already known that "&" should be escaped according to the standard. However, we were quite sure not escaping "&" would work, because everybody was not escaping it, but we were not so sure if escaping "&" would work in all cases. So we had chosen not to escape "&" to make sure the resulting image map work.
Having said that, I think the older browsers at that time had long been obsoleted, and the new browsers should support the standard quite well. So we may implement this in future versions of ChartDirector.
Regards
Peter Kwan |
|