Loading ...
Sorry, an error occurred while loading the content.

Re: [JavaScript] How to put more than one javascript code on a web page

Expand Messages
  • Tim Sabin
    This code can t be followed by a spam harvester, because the mailto url is put together in JavaScript. protect is a generic function, so you only need one
    Message 1 of 2 , Dec 31, 2007
    • 0 Attachment
      This code can't be followed by a spam harvester, because the "mailto"
      url is put together in JavaScript.

      protect is a generic function, so you only need one copy of it. What
      you DO need is one call for each address you want to protect:
      <script>protect("info", "davidfreed", "com", "contact us");</script>
      <script>protect("tim", "timsabin", "com", "contact me");</script>
      <script>protect("joe", "blow", "net", "Why?");</script>

      It doesn't matter if you have one <script> per address, or all in one,
      or as the URL in a <a href> tag (in which case, precede the code
      with "javascript:", or use this method:
      <a href="#" onClick="protect ('name', 'domain', 'com', '');">

      You can generate the proper code by using server-side code (PHP, Java,
      ASP, etc.).

      --Tim Sabin



      > I found this code for hiding email addresses from spam harvesting,
      and
      > I'd like to find out how to apply this to more than one email address
      > on a web page (for example, a list of contact names and emails).
      >
      > I don't know if I have to add a separate script for each email and if
      > I can, and how would I designate them as different, or is there a way
      > that I could do all this in a separate .js file?
      >
      > Best, David (PS - only a code beginner.)
      >
      >
      > <html>
      > <head>
      > <script>
      > function protect(name, address, end, display){
      > var link = name + "@" + address + "." + end
      > if(!display) { display = link; }
      > document.write("<a href='mailto:" + link + "'>" + display +
      > "</a>");
      > }
      > </script>
      > </head>
      >
      > <body>
      > <script>protect("info", "davidfreed", "com", "contact us");</script>
      > </body>
      > </html>
      >
      >
      >
      > Visit http://aiaiai.com for more groups to join
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.