T
Tony Strazzeri
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_addy(myUserName, mySubject )
{
var myAddress ="";
var myDomainNamePrefix = "winbusiness";
var myDomainNameType="com";
var myDomainNameLocation="au_address_from_addy";
var strDisplayTip=""
var atString = "^@^@^";
atString = atString.slice(1,2);
myAddress =myUserName + atString ;
myAddress =myAddress + myDomainNamePrefix + "." + myDomainNameType +
"." + myDomainNameLocation ;
strDisplayTip=myAddress
if ( mySubject ){myAddress = myAddress + '?subject=' + mySubject };
else {myAddress = myAddress};
document.write('<a href=\"mailto:' + myAddress + '\">' + strDisplayTip
+ '</a>');
window.status=strDisplayTip ;
}
'======== end [email_addy.js] =============
'======== start page html ===============
<html>
<head>
<script src="\scripts/email_addy.js" type="text/javascript"></script>
<script>
function generate_address(myUserName, mySubject )
{
var myAddress ="";
var myDomainNamePrefix = "myDomainName";
var myDomainNameType="com";
var myDomainNameLocation="au_address_from_inline";
var strDisplayTip=""
var atString = "^@^@^";
atString = atString.slice(1,2);
myAddress =myUserName + atString ;
myAddress =myAddress + myDomainNamePrefix + "." + myDomainNameType
+ "." + myDomainNameLocation ;
strDisplayTip=myAddress
if ( mySubject ){myAddress = myAddress + '?subject=' + mySubject };
else {myAddress = myAddress};
document.write('<a href=\"mailto:' + myAddress + '\">' +
strDisplayTip + '</a>');
window.status=strDisplayTip ;
}
</script>
</head>
<body>
Address using include: mailAddyMarker[myEmail]
<script language="javascript" type="text/javascript">
<!--
// The parameters for this are: Username,myDomainNamePrefix,
// Note: the order of these two is reversed from usual practice
// myDomainNameLocation,myDomainNameType
address_from_addy( "myEmail")
//-->
</script>
<!-- End: email address block -->
<hr>
Address using inline call: mailAddyMarker[myEmail]
<script language="javascript" type="text/javascript">
<!--
// The parameters for this are: Username,myDomainNamePrefix,
// Note: the order of these two is reversed from usual practice
// myDomainNameLocation,myDomainNameType
generate_address( "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_addy(myUserName, mySubject )
{
var myAddress ="";
var myDomainNamePrefix = "winbusiness";
var myDomainNameType="com";
var myDomainNameLocation="au_address_from_addy";
var strDisplayTip=""
var atString = "^@^@^";
atString = atString.slice(1,2);
myAddress =myUserName + atString ;
myAddress =myAddress + myDomainNamePrefix + "." + myDomainNameType +
"." + myDomainNameLocation ;
strDisplayTip=myAddress
if ( mySubject ){myAddress = myAddress + '?subject=' + mySubject };
else {myAddress = myAddress};
document.write('<a href=\"mailto:' + myAddress + '\">' + strDisplayTip
+ '</a>');
window.status=strDisplayTip ;
}
'======== end [email_addy.js] =============
'======== start page html ===============
<html>
<head>
<script src="\scripts/email_addy.js" type="text/javascript"></script>
<script>
function generate_address(myUserName, mySubject )
{
var myAddress ="";
var myDomainNamePrefix = "myDomainName";
var myDomainNameType="com";
var myDomainNameLocation="au_address_from_inline";
var strDisplayTip=""
var atString = "^@^@^";
atString = atString.slice(1,2);
myAddress =myUserName + atString ;
myAddress =myAddress + myDomainNamePrefix + "." + myDomainNameType
+ "." + myDomainNameLocation ;
strDisplayTip=myAddress
if ( mySubject ){myAddress = myAddress + '?subject=' + mySubject };
else {myAddress = myAddress};
document.write('<a href=\"mailto:' + myAddress + '\">' +
strDisplayTip + '</a>');
window.status=strDisplayTip ;
}
</script>
</head>
<body>
Address using include: mailAddyMarker[myEmail]
<script language="javascript" type="text/javascript">
<!--
// The parameters for this are: Username,myDomainNamePrefix,
// Note: the order of these two is reversed from usual practice
// myDomainNameLocation,myDomainNameType
address_from_addy( "myEmail")
//-->
</script>
<!-- End: email address block -->
<hr>
Address using inline call: mailAddyMarker[myEmail]
<script language="javascript" type="text/javascript">
<!--
// The parameters for this are: Username,myDomainNamePrefix,
// Note: the order of these two is reversed from usual practice
// myDomainNameLocation,myDomainNameType
generate_address( "myEmail")
//-->
</script>
<!-- End: email address block -->
<hr>
</body>
</html>
'======== End page html ===============