www.webdeveloper.com
Results 1 to 5 of 5

Thread: Need help replacing ampersand

  1. #1
    Join Date
    Feb 2005
    Posts
    8

    Need help replacing ampersand

    I saw a script on The Javascript Source web site a while ago. At least that's where I remember seeing it. It helped cut down on spambots getting your email.

    It wasn't the usual hide email address scripts. What it did was replace what ever symbol or series of characters you wanted with the ampersand (@) symbol.

    I'm trying to figure out how to recreate that but being somewhat of a novice at creating javascript, I'm at a loss. I can incorporate any scripts into my pages and get them to work, but I'm unable to create the code itself.

    Can anyone help me out?

    Werewolf_NC

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    The ampersand is the "&" character; the amphora is the "@" character. And you can replace characters or patterns of characters using the String.replace() method and regular expressions:

    <script type="text/javascript">
    <!--
    alert ('Fee, fie, foe, fum'.replace (/e/g, '@'))
    // -->
    </script>
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Dec 2002
    Location
    Manchester, UK
    Posts
    6,275
    I'm not sure how effective this would be, but couldn't you just replace the &#64; character with this:
    &amp;#64;

    That will produce the &#64; symbol but may hide it from bots. On my blog, I simply replace the &#64; symbol with the word "at". It gets the point accross and the bots are none the wiser.
    Every fight is a food fight when you’re a cannibal.

  4. #4
    Join Date
    Feb 2005
    Posts
    8
    I'm trying to make a mailto: link where they can click on the name of the person and get their default email program to send a message. If I put their full email in the mailto:, I don't want spambots to collect their email address.

    I can't use the &#64; because that only creates the image on the screen but it doesn't let me create that link.

    What I'm trying to do is switch something like address_*_something.com to address@something.com.

    Yes I was wrong, it wasn't the ampersand but the amphora symbol. Thanks for the correction.

  5. #5
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles