Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mailto prompt for confirmation 2

Status
Not open for further replies.

GuidoZ

Technical User
Nov 2, 2003
17
US
Hello again all! I found so many helpful people here last time I thought I'd throw this question up to you. It has me stumped more than I thought it would.

Here's the scoop. I have a mailto link that works perfectly fine. What I would like to do is have a javascript prompt with a short informational message, double-checking their reason to use the mailto link. (Getting a LOT of email that isn't necessary.) I'd like to have an "Ok" and "Cancel" button, which by clicking OK goes ahead with the mailto link, but clicking cancel does nothing.

For example, when they click the link (be it still a mailto link or not), I'd like a javascript box to pop up and say "If you need blah blah, then click cancel and go to blah blah. Otherwise click OK to continue." Clicking OK then acts like a normal mailto link would if there was never a javascript at all. Clicking cancel simply cancels all action.

I've searched high and low on the web (Google, pages deep) and even here (Closest match is: thread216-104402 ) without any luck. That last link I posted looks very similar to my question, however it was never answered unfortunately.

I've seen you good javascript programmers come to the rescue many times, would greatly appreciate someone to point me in the right direction of a FAQ/Tutorial. Of course code is greatly appreciated too. =) Thanks guys, looking forward to your replies.

GuidoZ
 
If you are receiving unwanted mail, it might be through the use of email scrapers visiting your website. These are similar to search engine spiders, but look for email addresses instead of indexing your site.

You can encode the "@" and "." to confuse some of them, but the only real way is to use a "web" version of your email address that you can afford to shut down.

Code:
The "@" symbol replaces with @
The "." symbol replaces with .

Hence your link would be in the format of:
Code:
mailto:someone@somewhere.com

Alternatively, you can use JavaScript to output a dynamically generated link that will only view correctly by a browser.

To get your email "confirm" to work, try (I've included both version - HTML and JavaScript):
Code:
<html>
<head>
	<title>Link Colors</title>
</head>

<script language=&quot;JavaScript&quot;>
function confirmSubmit() {
	var agree=confirm(&quot;Are you sure you wish to continue?&quot;);
	if (agree)
		return true ;
	else
		return false ;
}
</script>
<body>
Text version: <a href=&quot;mailto:someone&#64;somewhere&#46;com&quot; onclick=&quot;return confirmSubmit();&quot;>Mail me</a><br>
JavaScript version:
<script language=&quot;JavaScript&quot;>
document.write(&quot;<a href=\&quot;mailto:&quot;);
document.write(&quot;someone&#64;&quot;);
document.write(&quot;somewhere&#46;&quot;);
document.write(&quot;com\&quot; onclick=\&quot;return confirmSubmit();\&quot;>&quot;);
document.write(&quot;Mail me&quot;);
document.write(&quot;</a>&quot;);
</script>
</body>
</html>

Hope this helps...

Pete.


Web Developer / Aptrix CMS (LWWCM) Specialist
w: e: Pete.Raleigh(at)lclimited.co.uk
 
GuidoZ,

Try this:

Code:
<html>
<head>
<script type=&quot;text/javascript&quot;>
<!--
	function confirmMailTo() { return(window.confirm('Do you really want to send an email?')); }
//-->
</script>
</head>
<body>

Click <a href=&quot;mailto:billg@msg.microsoft.com&quot; onClick=&quot;return(confirmMailTo());&quot;>here</a> to email Bill Gates

</body>
</html>

To have the functionality on mulitple links, simply add the onClick action to any link that you want this behaviour on.

Hope this helps!

Dan
 
Bummer... after previewing about 4 times the @ symbol still didn't encode properly. I'd used the CODE and IGNORE codes, and even encoded the AMPERSAND character. My preview looked fine - until I posted it! :-(

The @ symbol encodes to &quot;&_#_6_4_;&quot; - ie. hash64
The . symbol encodes to &quot;&_#_4_6_;&quot; - ie. hash46
Just remove the &quot;_&quot; and quotes.

Pete.


Web Developer / Aptrix CMS (LWWCM) Specialist
w: e: Pete.Raleigh(at)lclimited.co.uk
 
&quot;I love you guys.&quot; *Said like Cartman from Southpark*

Both ways worked perfectly! Both will get a star for that... now I just gotta figure out which to use. =P Thanks so much for the help.

Pete, nice thoughts on the encoding. I was actually aware of the problems, however I didn't realize I could do it that way in javascript. The emails we were getting were due to confused visitors (hence the double-check), however spam is becoming a small problem. I think I'll pop that idea in too, just to help. =)

Thanks again boyz. Ya done good. ;)

~ GuidoZ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top