tags:

views:

62

answers:

4

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  A: 

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.

Gert G
the reason I approached it this way was because I already have a function that pulls from the title, and I needed prettyphoto to pull the description text from somewhere else. So I used longdesc.
Jason
Using it for anything else than what it was intended for will render it useless for screen readers.
Gert G
anyway then to get html into alt?
Jason
Keep in mind that `longdesc` is [no longer valid in HTML5](http://www.whatwg.org/html5/#attr-img-longdesc).
Christopher Parker
+3  A: 

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/\'&gt;Link&lt;/a&gt;');" onmouseout="UnTip();">
Christian Sciberras
A: 

Are you looking for the html entities?

If so, these are what you are looking for:

&gt; = >

&lt; = <

&#34; = "

&#39; = '

Aaron Harun
anyway to do a replace with jquery automatically?
Jason
You can get the contents of the londgesc with:`jQuery("image").attr("longdesc");`The just perform a regex to pull out the link.
Aaron Harun
See my answer below to replace entities in jquery automatically.
Dustin Fineout
hmmm...great comments and answers. I need a lightbox that allows for html in descriptions that's can be redistributed. That's my real issue.
Jason
It's the 4th item down on the page. http://www.lokeshdhakar.com/projects/lightbox2/#support
Aaron Harun
And an alternative method for the same script: http://www.saurdo.com/01/03/using-html-in-a-lightbox-description
Aaron Harun
But, I need one more like prettyphoto, fancybox, etc. that can do multiple types of content.What I really need is a port of phatfusion multibox to jquery...
Jason
+2  A: 

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/"&gt;Link&lt;/a&gt;

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/"&gt;Link&lt;/a&gt;
</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;
Dustin Fineout