views:

50

answers:

2

A user clicks a link in their HTML email, it then goes to a page that simply opens up their email client.

 window.location.href = 'mailto:...';

I don't want this window/tab to stay open, how can I close it?

window.close() doesn't work since it wasn't opened using window.open()

is it possible?

+1  A: 

The browser does not control the mail client, period. It launches an APPLICATION, not a window.

Diodeus
yes, but I want the window/browser that launches the application to close after it launches the application.
Blankman
If browsers had control over other applications, we'd be in big trouble. It would be a serious security breach.
Diodeus
But I'm not even asking the browser to control other applications. I am asking for the browser to close itself once the other application launches. window.close() that's all (which doesn't work).
Blankman
You cannot close a browser using script that was not opened using script. I certainly would NEVER want a web site to be closing MY browser.
Diodeus
window.open('', '_self', ''); window.close(); works in IE, so it is possible.
Blankman
@Blankman, yeah actually it's possible but work only with IE. I think there would be an equivalent for window.close in other browsers.
Omar Abid
A: 

I agree with @Diodeus: using a mailto: link opens an external application which you cannot control via your browser. Even if you could close the window that a web email application loaded, you can't guarantee everyone would launch a webmail app on a mailto: link. Some of us use Exchange/Outlook at work, for example.

If you really want to control the user experience of sending an email from your application, skip mailto: links altogether and offer a page/form that allows the user to enter the email body/subject.

You then process the form and send the email using whatever server-side technology you're using. This can have the benefit of not exposing your email address to spambots.

Randolpho