Tuesday, August 18, 2009

mailto: link in a HTML Popup

Today I had to use a HTML Popup to display some person details, including and email address.

To get the email link to launch a new email window I thought I could just insert the mailto: markup into the anchor in the popup body, however it did not respond.

I found that to get this to work I needed to insert my popup content into a DIV, pass the DIV content as the content for the popup body, and have the onclick event on the mail address anchor make a call to get the parent window to navigate to the mailto: URL.

All a bit cludgey, but it worked in the end. The resulting HTML looked like this:

<DIV id="data1" style="display:none">
<SPAN onclick="javascript:parent.window.navigate('mailto:xxxxxx@xxxx.xxx.xx')">
<B>Email:</B><a href="#" >xxxxxx@xxxx.xxx.xx</a></SPAN>
<BR> ... more HTML ...

<a href="#" onclick="javascript:
var oPopup = window.createPopup();
var oPopBody = oPopup.document.body;
oPopBody.style.backgroundColor = 'lightyellow';
oPopBody.style.border = 'solid black 1px';
oPopBody.innerHTML = data1.innerHTML;
oPopup.show(0, 16, 350, 75, event.srcElement);" style="text-decoration:none" >...</a>

No comments:

Post a Comment