How do I add html link to image title

五迷三道 提交于 2019-12-09 01:19:54

问题


I'm actually needing to include html links in the longdesc attribute. I've altered prettyphoto to use longdesc instead of title for images, but I need to include html links in those descriptions. I know it's possible with code for characters, I just don't remember what those are.

Thanks


回答1:


This can be done with the longdesc attribute:

<img src="theimage.png" longdesc="thedescription.html" />

And then, in thedescription.html:

<a href="http://test.com/">Link</a>

One alternative way to do this is by using an OBJECT element, as follows:

<OBJECT data="theimage.png" type="image/png">
    <a href="http://test.com/">Link</a>
</OBJECT>

Also, since you asked for it, here is how to convert html entities automatically in jquery:

$('<div/>').text('<a href="link.html">Some Link</a>').html();
// the above evaluates to &lt;a href=&quot;link.html&quot;&gt;Some Link&lt;/a&gt;



回答2:


I'm not sure if this is what you're looking for, but you can use Walter Zorn's wz_tooltip to show a tooltip with any kind of content.

And example of use:

<img src="theimage.png" onmouseover="Tip('<a href=\'http://test.com/\'>Link</a>');" onmouseout="UnTip();">



回答3:


The longdesc attribute is an URI, not a place to add code. In other words, you'll need to create a page that the longdesc links to. This page is where you'll make a thorough description of what's on the image.




回答4:


Are you looking for the html entities?

If so, these are what you are looking for:

&gt; = >

&lt; = <

&#34; = "

&#39; = '



来源:https://stackoverflow.com/questions/3032828/how-do-i-add-html-link-to-image-title

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!