问题
I want to make one word of a sentence as a hyperlink. I have written it as : Click on our <a href="http://www.google.co.in"> website </a> to know the details. The markup property of the text field is also selected as "html". But the hyperlink is not created. Please help.
回答1:
The HTML markups are only intended for the purpose of styling a text field. You are looking for the "Hyperlink" option. It doesn't work for static text fields though, but when you right click on a text field you should find the item "Hyperlink" in the context menu. This allows you to link the field to an anchor, another report or a webpage.
回答2:
Hyperlinks are not supported by static text fields - they only work with text field.. it worked when i used a text field and as the expression entered static text in quotes "click here etc" Then add a hyperlink by selecting hyperlink from the context menu..
回答3:
I know the question is pretty old, but if somebody need a code, I will add it here:
<textField>
<reportElement positionType="Float" x="220" y="45" width="406" height="60"/>
<textElement markup="html">
<font fontName="Arial" size="8"/>
</textElement>
<textFieldExpression><![CDATA["Click on our"+"<u><font color='blue'><a href='http://www.google.co.in'>website</a></font></u>"]]>
</textFieldExpression>
</textField>
回答4:
The htm markup seems to be extremely limited. I have only found that it works for very basic html formating such as <i> and <b> tags. I do not think anchors or lists or any 'fancier' markup with do anything.
来源:https://stackoverflow.com/questions/2818439/a-html-tag-used-for-hyperlink-doesnt-work-in-jasper-report