Hi all,
I a fairly new to html and Javascripting. I have been trying to write
some code to hide my email address from spam harvesters. I copied the
code from various web examples and modified it to suit me.
The code to generate the address is in a js include file. I am using
frontpage 2003 to create my web pages. My problem is that the code
works OK when I test it using Frontpage's 'Preview' but does not work
when I display the page in an actual browser (IE or Firefox).
The same code works OK if I have it inline but not when I place the
code in an include file.
Can someone tell me what I am doing wrong?
The include file is is called 'email_addy.js' and is stored in a folder
called 'scripts/' off the page root.
The javascript code for the include is below. The html for the page
follows it.
Cheers
Tony.
'========start [email_addy.js] ==========
function address_from_ad dy(myUserName, mySubject )
{
var myAddress ="";
var myDomainNamePre fix = "winbusines s";
var myDomainNameTyp e="com";
var myDomainNameLoc ation="au_addre ss_from_addy";
var strDisplayTip=" "
var atString = "^@^@^";
atString = atString.slice( 1,2);
myAddress =myUserName + atString ;
myAddress =myAddress + myDomainNamePre fix + "." + myDomainNameTyp e +
"." + myDomainNameLoc ation ;
strDisplayTip=m yAddress
if ( mySubject ){myAddress = myAddress + '?subject=' + mySubject };
else {myAddress = myAddress};
document.write( '<a href=\"mailto:' + myAddress + '\">' + strDisplayTip
+ '</a>');
window.status=s trDisplayTip ;
}
'======== end [email_addy.js] =============
'======== start page html ===============
<html>
<head>
<script src="\scripts/email_addy.js" type="text/javascript"></script>
<script>
function generate_addres s(myUserName, mySubject )
{
var myAddress ="";
var myDomainNamePre fix = "myDomainNa me";
var myDomainNameTyp e="com";
var myDomainNameLoc ation="au_addre ss_from_inline" ;
var strDisplayTip=" "
var atString = "^@^@^";
atString = atString.slice( 1,2);
myAddress =myUserName + atString ;
myAddress =myAddress + myDomainNamePre fix + "." + myDomainNameTyp e
+ "." + myDomainNameLoc ation ;
strDisplayTip=m yAddress
if ( mySubject ){myAddress = myAddress + '?subject=' + mySubject };
else {myAddress = myAddress};
document.write( '<a href=\"mailto:' + myAddress + '\">' +
strDisplayTip + '</a>');
window.status=s trDisplayTip ;
}
</script>
</head>
<body>
Address using include: mailAddyMarker[myEmail]
<script language="javas cript" type="text/javascript">
<!--
// The parameters for this are: Username,myDoma inNamePrefix,
// Note: the order of these two is reversed from usual practice
// myDomainNameLoc ation,myDomainN ameType
address_from_ad dy( "myEmail")
//-->
</script>
<!-- End: email address block -->
<hr>
Address using inline call: mailAddyMarker[myEmail]
<script language="javas cript" type="text/javascript">
<!--
// The parameters for this are: Username,myDoma inNamePrefix,
// Note: the order of these two is reversed from usual practice
// myDomainNameLoc ation,myDomainN ameType
generate_addres s( "myEmail")
//-->
</script>
<!-- End: email address block -->
<hr>
</body>
</html>
'======== End page html ===============
I a fairly new to html and Javascripting. I have been trying to write
some code to hide my email address from spam harvesters. I copied the
code from various web examples and modified it to suit me.
The code to generate the address is in a js include file. I am using
frontpage 2003 to create my web pages. My problem is that the code
works OK when I test it using Frontpage's 'Preview' but does not work
when I display the page in an actual browser (IE or Firefox).
The same code works OK if I have it inline but not when I place the
code in an include file.
Can someone tell me what I am doing wrong?
The include file is is called 'email_addy.js' and is stored in a folder
called 'scripts/' off the page root.
The javascript code for the include is below. The html for the page
follows it.
Cheers
Tony.
'========start [email_addy.js] ==========
function address_from_ad dy(myUserName, mySubject )
{
var myAddress ="";
var myDomainNamePre fix = "winbusines s";
var myDomainNameTyp e="com";
var myDomainNameLoc ation="au_addre ss_from_addy";
var strDisplayTip=" "
var atString = "^@^@^";
atString = atString.slice( 1,2);
myAddress =myUserName + atString ;
myAddress =myAddress + myDomainNamePre fix + "." + myDomainNameTyp e +
"." + myDomainNameLoc ation ;
strDisplayTip=m yAddress
if ( mySubject ){myAddress = myAddress + '?subject=' + mySubject };
else {myAddress = myAddress};
document.write( '<a href=\"mailto:' + myAddress + '\">' + strDisplayTip
+ '</a>');
window.status=s trDisplayTip ;
}
'======== end [email_addy.js] =============
'======== start page html ===============
<html>
<head>
<script src="\scripts/email_addy.js" type="text/javascript"></script>
<script>
function generate_addres s(myUserName, mySubject )
{
var myAddress ="";
var myDomainNamePre fix = "myDomainNa me";
var myDomainNameTyp e="com";
var myDomainNameLoc ation="au_addre ss_from_inline" ;
var strDisplayTip=" "
var atString = "^@^@^";
atString = atString.slice( 1,2);
myAddress =myUserName + atString ;
myAddress =myAddress + myDomainNamePre fix + "." + myDomainNameTyp e
+ "." + myDomainNameLoc ation ;
strDisplayTip=m yAddress
if ( mySubject ){myAddress = myAddress + '?subject=' + mySubject };
else {myAddress = myAddress};
document.write( '<a href=\"mailto:' + myAddress + '\">' +
strDisplayTip + '</a>');
window.status=s trDisplayTip ;
}
</script>
</head>
<body>
Address using include: mailAddyMarker[myEmail]
<script language="javas cript" type="text/javascript">
<!--
// The parameters for this are: Username,myDoma inNamePrefix,
// Note: the order of these two is reversed from usual practice
// myDomainNameLoc ation,myDomainN ameType
address_from_ad dy( "myEmail")
//-->
</script>
<!-- End: email address block -->
<hr>
Address using inline call: mailAddyMarker[myEmail]
<script language="javas cript" type="text/javascript">
<!--
// The parameters for this are: Username,myDoma inNamePrefix,
// Note: the order of these two is reversed from usual practice
// myDomainNameLoc ation,myDomainN ameType
generate_addres s( "myEmail")
//-->
</script>
<!-- End: email address block -->
<hr>
</body>
</html>
'======== End page html ===============
Comment