mailto: link opening new browser window in Netscape

C

Ciar?n

Hi all,
I've go a little mailto: link on a page that when clicked opens an
email form with the email address in the To field - all very simple.
Problem is that in Netscape, a new blank window is opened up as well,
along with the email form. Is there a way to stop this blank window
from opening? Below is the relevant code. My test browsers are IE 6
and NS 7.

function openwindow(location,width,height,name){

window.open(location,width,height,name);
}

<a href="javascript:void(0)"
onClick="openwindow('mailto:[email protected]','790','571','summary')"><img
src="..generic/weblink.gif" border="0" /></a>
 
T

Thomas 'PointedEars' Lahn

Ciar?n said:
I've go a little mailto: link on a page that when clicked opens an
email form with the email address in the To field - all very simple.
Problem is that in Netscape, a new blank window is opened up as well,
along with the email form. Is there a way to stop this blank window
from opening?

Yes, do not use your user-defined openwindow(...) method that calls
window.open(...). If supported, `mailto:' URIs already open a mail
compose window.
[...]
<a href="javascript:void(0)"
onClick="openwindow('mailto:[email protected]','790','571','summary')"><img
src="..generic/weblink.gif" border="0" /></a>

That hyperlink will not work without JavaScript and is therefore a Bad
Thing. Besides, `mailto:' URIs are not recommended since they fail if
there is no mail client installed or if one is installed but not
configured for the HTTP user agent (browser). Use a contact form and a
server-side form-mailer instead.

You should at least use

<a href="mailto:[email protected]"
<img src="..generic/weblink.gif" border="0" /></a>

if you don't want to use a form-mailer.


PointedEars
 
F

Fox

You open a new window! That's what you get: a new window! Simple. Be glad
you GET a new window. It means Moz works. Dont make things to difficult and
just do:

<a href=mailto:[email protected]>Send email</a>

The "mailto:" protocol will start a procedure to launch a mail program, but
you do TWO things: launch an email app + creating a new window.

I think that's it :)

http://www.amabuy.com
 
L

Lasse Reichstein Nielsen

Fox said:
<a href=mailto:[email protected]>Send email</a>

Just to nitpick: The href attribute value must be quoted, since it
contains a "@".
It is *much* safer to quote all attribute values than to worry about which
ones are allowed to be unquoted.

/L
 
F

Fox

I like quotes too, but Outlook Express (yesyes) is a magical program which
behaves in its own special way: it removes the quotes sometimes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top