problem with Javascript code from Include

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 ===============
 
T

Tony Strazzeri

Hi,

Thank you both for your response.

I have tried various combinations of the path and done the edits in
notepad then used ftp to transfer the edited file.

putting a dot before the first slash seemed to do the trick
<script src="./scripts/gen_email.js" type="text/javascript"></script>

Funny though... I am sure I had already tried that.
I also made the change using Frontpage and used it to upload the pages
and that still worked.

BTW.
I know it was a small amount of code and it could have been placed
directly into each page, but I was using the code in several pages
(some of which were in nested folders). So I wanted to keep it in one
location.

I still wanted toi see how to deal with this in case I needed to use
the technique in the future.

Thanks both.

Tony.

PS now I have another question, but I'll post it separately it's to do
with putting a marker on the page visible at design time and have it
replaced by the address at runtime.
 
R

Randy Webb

Thomas said:
[stripped X-Post to microsoft.public.frontpage
since no such group exists on this server]

Then why did you set follow-up to a group that does not exist "on this
server" ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top