简体   繁体   English

Java / HTML-换行符在标题中起作用,但在alt属性中不起作用(IE8)

[英]Java / Html - Linebreaks work in title but not in alt attribute (IE8)

I want to display an image with a title and an alt attribute. 我想显示带有标题和alt属性的图像。 They both display the same content which is stored in a variable. 它们都显示存储在变量中的相同内容。 Before displaying I replace all occurences of "\\n" with " ". 在显示之前,我将所有出现的“ \\ n”替换为“”。 Now the interesting part: When hovering over the image, the title displays the text correctly (sentence under sentence) but the alt text shows " " instead of breaking the lines. 现在有趣的部分:将鼠标悬停在图像上时,标题正确显示了文本(句子下的句子),但是替代文本显示为“”,而不是换行。

What the heck is going on? 到底他妈发生了什么? O_o O_o

Thanks for your help! 谢谢你的帮助!

EDIT: 编辑:

        ...
        tooltipText = tooltipText.replaceAll("\n", "
");
        startElement(HTML.IMG_ELEM, someName);
        writeAttribute(HTML.TITLE_ATTR, tooltipText);
        writeAttribute(HTML.ALT_ATTR, tooltipText);
        ...

I googled around and found this other question on Stack Overflow that may help you: newline in <td title=""> 我四处搜寻,发现了另一个有关堆栈溢出的问题,可能会对您有所帮助: <td title =“”>中的换行符

edit - tested on Firefox 14.0.1 (Ubuntu). 编辑-在Firefox 14.0.1(Ubuntu)上进行了测试。 Can't test with IE8, though. 但是无法使用IE8进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM