Forum Moderators: open

Message Too Old, No Replies

Code to start an email AND open a web page?

         

kapow

12:10 pm on Jul 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For some time I have been looking for code to both start an email and to open a web page.

1.) The email: i.e. a link that opens a new email in your mail client, something that produces the same effect as: <a href="mailto:me@mydomain.com">email me</a>.

and

2.) Open a web page: A thankyou php page with some code that increments the count of emails from the website.
(have got the php code and taken precautions against spambots).

I have been trying to do this for months. Today I figured out a way of doing it. However so many people told me it couldn't be done that I would like to ask if my code will create a problem. It works on my PC with IE-6.

My code (Got this code via DreamWeaver, I'm not a javascript expert!):

<head>
<script language="JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>

<body>
<a href="#" onClick="MM_goToURL('parent','mailto:fred@domain.com');MM_goToURL('parent','thankyou.php');return document.MM_returnValue">email
link</a>
</body>

Will this work in general browsers?
Can anyone think of a simpler way of doing it?

killroy

2:43 pm on Jul 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd like to point out that mailto: has been deprecated and you should not use it at all.

SN

tedster

6:17 pm on Jul 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could you supply a reference for the deprecation of the mailto: URI? I haven't seen anything about that.

claus

6:42 pm on Jul 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



suggestion:

<a href="mailto:me@mydomain.com" onClick="javascript:window.location.href='www.something.com'">email me</a>

There's a space after the com"

- don't know about the deprecated part, i do not usually put mail addresses on webpages.

/claus

<edit> i see from your DW code that you might have to use "parent" in stead of "window" - possibly because you use frames. If not it's just DW that suck :) </edit>

g1smd

7:43 pm on Jul 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Umm, I would hate a page that opens two windows at the same time, or opens a new browser window as well as my email program.

I would provide an on-screen script-driven email-form with submit button, and a completely separate email link for those who want to send you email via their email program. However, opening two windows is not a good idea.

You'll need to hide the email address from spiders too. See [webmasterworld.com...] for more.

claus

7:45 pm on Jul 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>> two windows is not a good idea

i agree ...the example i gave will not open a new window. It just changes the url of the current window ;)

kapow

11:13 am on Jul 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



and a completely separate email link for those who want to send you email via their email program.
That is what I want to track. I can easily track when a visitor completes a form but I want to track how many click the ordinary email link.

You'll need to hide the email address from spiders too.
I did say: "...I have taken precautions against spambots". To be specific, I use: [hiveware.com...]

THANKYOU CLAUS!
This seems to work much better - and doesn't have all that extra DW code :)
<a href="mailto:me@mydomain.com" onClick="javascript:window.location.href='thankyou.php'">email me</a>

Thanasus

11:20 am on Jul 6, 2003 (gmt 0)

10+ Year Member



One of the things to keep in mind wich mailto links is that they do not work on any sort of computer which doesn't have email software installed.... ie, public computers, shared computers, some work computers where users dont have install permissions...

I have typically always favored web based forms. Also lets you get out numerous environment variables you can put in the email too.

peewhy

11:24 am on Jul 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Which gives us a reminder that we still don't have a common platform ...yet and something as simple as putting an email link on a website may not be that simple at face value ;)