Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Antispam Javascript for CONTACT US


Sinister-Racing

Recommended Posts

I have used this script before for the typical mailto:[email protected] code to prevent spam. I suggest everyone uses it on their website to prevent spam, but for some reason I am having a problem in PHP.

 

Here is the javascript portion:

<script language="javascript" type="text/javascript"><!--

//ANTI-SPAM

//Works: IE+4, NS6+, Opera

function antispam(name,domain) {

document.location = "mailto:" + name + "@" + domain;

}

//-->

</script>

 

Here is the link portion:

<a href="#" onclick="antispam('contact','domainname.com');return false">[email protected]</a>

 

------------------------------------------------------------------------------

 

The problem I am having with the link code is the single quotes around contact & domainname.com. If I leave the single quotes around them I get a "parse error, unexpected T_STRING...."

If I change them to double quotes the parse error disappears and the page loads normal but when I click on the link it doesn't do the javascript function and I return to catalog/#.

 

Also I this code is being used in my contact_us.php LANGUAGE page under define('TEXT_BODY'.....

I tried to make a antispam.js and access the code via $javascript = 'antispam.js'; right under the

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CONTACT_US); in the main contact_us.php but no luck.

I also tried putting the actual javascript before the php code in the main contact_us.php page with once again no luck.

 

Any help would be greatly appreciated and hopefully when this is fixed I can turn it into a quick little contribution with due credit given to the helper.

 

Thanks,

 

Michael

Link to comment
Share on other sites

Hi,

 

Try using this in the appropriate languages file.

 

<script type="text/javascript" language=javascript>
<!--
var username = "Customer.Service";
var hostname = "Domain.com";
var linktext = username + "@" + hostname;
document.write("<a href=" + "mail" + "to:" + username +
"@" + hostname + ">" + linktext + "<\/a>")
//-->
</script>
<!-- js ends -->
<noscript>Customer.Service at Domain.com</noscript>

 

Cheers,

EricK

Link to comment
Share on other sites

What is this used for?

<noscript>Customer.Service at Domain.com</noscript>

That is optional, it will display only in browsers with Javascript disabled.

 

Also how do I define the normal <a href=mailto:[email protected]>[email protected]<a/> link?

Replace it with the code above, of course replace Customer.Service with your email address before the @ symbol, and replace Domain.com with your email address after the @ symbol.

 

-EricK

Link to comment
Share on other sites

The problem with that code is that the script is not changing anything. There is still a copyable link that takes you to mailto:[email protected]

 

Check out http://www.wisewaycustompools.com/bridge/

 

Look at the top right corner where it says contact. You click on it and it will take you to your mail box with the correct address, but when you hover over it or copy the link it shows http://www.wisewaycustompools.com/bridge/#

 

Therefore you will not receive spam because there is no address to copy.

 

Let me know if that makes any sense. It has been a long day.

 

Thanks,

 

Michael

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...