Forum Moderators: phranque

Message Too Old, No Replies

Encoded mailto text link gives me 404 error

No javascript

         

Kickedout

7:41 pm on May 3, 2012 (gmt 0)

10+ Year Member



I'm implementing a simple mailto link, but just econded the email to avoid spam (I don't want to use javascript). However is not working when I click it I get this on browser address bar


http://www.example.com/mailto:informes@ba
?Subject=Mysubject%20Bla

Seems like is not understanding is a mailto link.

What's the problem?

code I use on html body
!-- #BeginLibraryItem "/Library/languages-brasil.lbi" -->

[edited by: phranque at 7:39 am (utc) on May 4, 2012]
[edit reason] edited to fix sidescroll [/edit]

Staffa

7:59 pm on May 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this one :

<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#105;&#110;&#102;&#111;&#114;&#109;&#101;&#115;&#64;
&#98;&#229;&#114;&#105;&#108;&#111;&#99;&#104;&#101;&#46;&#101;&#115;&#112;&#46;&#98;&#114;">Contato</a>

[edited by: phranque at 8:25 pm (utc) on May 3, 2012]
[edit reason] fixed sidescroll [/edit]

Kickedout

8:11 pm on May 3, 2012 (gmt 0)

10+ Year Member



Thank you. I did.

It doesn't work inside the library item (is exactly the same code, but without the subject thing)...

It does work outside the library item. The problem is that link has to be in my nav bar.

What's wrong with putting it inside the library? Any workaround?

londrum

8:18 pm on May 3, 2012 (gmt 0)

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



you've got it looking like a URL, with a domain name at the beginning. you don't need that for a mailto address.
it should look something like this

<a href="mailto:someone@example.com?subject=Title">blah</a>


so you need to encode this bit...
mailto:someone@example.com?subject=Title


... if its not working maybe you've got a base href set in the <head> ? it might be adding the domain name to the beginning because of that

[edited by: londrum at 8:28 pm (utc) on May 3, 2012]

Kickedout

8:28 pm on May 3, 2012 (gmt 0)

10+ Year Member



Why do you say that? My code is exactly a mailto link but just encoded..

londrum

8:31 pm on May 3, 2012 (gmt 0)

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



because you said when you click it, you get taken to http://www.example.com..blah blah in the address bar.
that doesnt happen with a mailto link

hover over the mailto link, and see what it says in the status bar

Kickedout

8:39 pm on May 3, 2012 (gmt 0)

10+ Year Member



Seems you have a point.
Hovering shows
http://www.example.com/&#109;&#97;&#105;&#108;&#116;&#111;:
&#105;&#110;&#102;&#111;&#114;&#109;&#101;&#115;&#64;&#98;&#97;&#114;&#105;&#108;&#111;
&#99;&#104;&#101;&#46;&#101;&#115;&#112;&#46;&#98;&#114;?Subject=Contato%20from%20www.example.

How do I get rid of the http://www.example.com part?

[edited by: phranque at 7:41 am (utc) on May 4, 2012]
[edit reason] edited to fix sidescroll [/edit]

phranque

7:43 am on May 4, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you need to use an href attribute value which doesn't look like a relative url to the browser, which means you probably have to leave at least the url scheme (mailto:) unencoded.

Kickedout

7:26 pm on May 4, 2012 (gmt 0)

10+ Year Member



Thanks! But sadly didn't work. Doing such a thing results in mailto working opening email client but in TO field appears literally: "&#109;&#101;&#115;&#64;&#98;&#97;&#114;&#105;&#108;&#111;
&#99;&#104;&#101;&#46;&#101;&#115;&#112;&#46;&#98;&#114"

So no joy either.

londrum

7:36 pm on May 4, 2012 (gmt 0)

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



encoding it won't protect it from spambots anyway, it's an old-school trick, about a hundred years old.

if it's protection from spambots you're after, then it's probably no protection at all.

what's the problem with using javascript? at least you'll get a little bit of protection with that.

Kickedout

8:24 pm on May 4, 2012 (gmt 0)

10+ Year Member



old school or not worked fine to me for years, no complains. but doesn't into library items, what is a problem. (I'll have to move to jscript seems)

Kickedout

10:12 pm on May 4, 2012 (gmt 0)

10+ Year Member



I couldn't find a javascript allowing body variable in several lines.
Like:
"please tell us about you

name:
age:
and so on:
"

That's something actually I can do with my old school technique.

londrum

3:33 pm on May 5, 2012 (gmt 0)

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



you dont need to javascript the whole thing, just the email address. the rest of the mailto link (including the subject and body variables) can be written like normal.

if you google "javascript email obfuscation" you'll get loads of ways to hide it