Question

Sorry about the provocative subject but I could not think of a better word than "hack" to describe what I would like to do!

On my site, I provide links to other sites and on request by the user, display a page from the site in a frame or pop up window. Frequently these displayed pages have a mailto-tag.

I have found it extremely annoying that clicking the mailto link starts off my outlook which I no longer use but retain it as an installed program on my machine.

What I would like to do is:

1) Pick up the subject and email address part of the mailto tag. 2) Pop up an HTML form where the email address and the subject is prefilled. 3) Send the email message through my site's mailserver instead of through outlook or any other mail client.

Is there a way to do this?

Thank you in advance - and once again apologies for the provocative subject line!

Cheers!

Uttam

Était-ce utile?

La solution

Try it using javascript.

With using a framework like jQuery its easy so find such tags inside a frame or popup window. You can try it by something like this:

var allATags = $('myFrameId').find('a');
$(allATags).each(function(index, element){
    var href = $(element).attr('href');
    //here you shall try to find out if there a mailto Link or a normal link, e.g. using regular expression or indexOf()
    [...]
    if (isMailToLink){
        //split the href String at the signs '&' with which the subject, mail, etc is splitted and removing the mailto, putting all in own variables
        [...]
        $(element).attr('href', 'javascript:void(0);');
        $(element).click(function(){
           showMyMailForm(toMail, mailSubject, mailBody);
        });
    }
});

On opening a document in a frame or a popup wait for the document being loaded and then run your code to replace all existing mailto-links on that document with your mailform-mailer.

The code is just a way trying to inspire, no working code.

Autres conseils

Users can set their default email client, here are a couple of links that may be helpful:

Of course this is controlled by the user, so it will help you personally, but not force others to use a specific program.

You could easily pass url parameters onto your contact landing page/email form instead of a mailto link, something like a href="http://landingpage.com/index.php?email=you@you.com&subject=hello" could be used to pre-fill generic contact/email form fields.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top