473,785 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with Javascript code from Include

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

Jul 23 '05 #1
5 1866
Check the path of the include file. Try <script
src="scripts/email_addy.js" type="text/javascript"></scrip*t>.
The javascript is not big, why not copying it to start_page.html ?

SCDeveloper
http://www.sharingcorner.com

Jul 23 '05 #2
"Tony Strazzeri" <st****@my-Deja.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
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.


Someone else mentioned to check the path - FrontPage likes to put its own
path in, so you need to override that. I have the same problem with images
in FrontPage, too.

That's why I usually do stuff like this with a text editor...
Jul 23 '05 #3
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.

Jul 23 '05 #4
[stripped X-Post to microsoft.publi c.frontpage
since no such group exists on this server]

Tony Strazzeri wrote:
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
Yes, it *seems to be* that way. However, it *is* not so.
<script src="./scripts/gen_email.js" type="text/javascript"></script> ^^ ^^^^^^^^^^^^
If you would care to compare with the original version:

| <script src="\scripts/email_addy.js"
^ ^^^^^^^^^^
| type="text/javascript"></script>
Funny though...
Not at all.
I am sure I had already tried that.
You have not only put a dot before the first slash but you have also turned
a wrong backslash into the correct forward slash. The dot-slash, however,
is completely unnecessary (and should not change anything, else your server
is definitely borken) as it only specifies the source document path.
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.


Are you also going to tell us what you are going to do next week?
PointedEars
Jul 23 '05 #5
Thomas 'PointedEars' Lahn wrote:
[stripped X-Post to microsoft.publi c.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" ?

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2310
by: Aaron Prohaska | last post by:
I have just run into a problem where I have a page that posts back to itself to execute code, except when the page does the post back it somehow executes code that is in our home page for the site. The only reason I know that is happening is because I keep track of the pages executed by the user to see how they have traversed the site. Has anyone every seen anything like this before? Regards, Aaron Prohaska
1
3257
by: Kevin Potter | last post by:
We have an application that has been running on IIS4 and IIS5 for quite some time, without problem We're now migrating to IIS6 (windows/2003), and have run into a what might? be a Javascipt problem/question... The snippet of code in question is: <script language="JavaScript"><!-- document.write("<script src='/fp/"+includename+"'></script>"); // -->></script>
12
9645
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" & Chr(34) & PopUpWindowTitle & Chr(34) & ", " & Chr(34) & CurrentEventDetails & ")" strTemp += "<BR><A HREF='#' onClick='" & PopupLink & "'>" & EventName & "</A><BR>" The problem I have is that when the string variables or contain a string with an...
4
7779
by: Miguel Dias Moura | last post by:
Hello, I am having problems in accessing controls in my Asp.Net 2.0 pages. I know Asp.Net 2.0 generates a ClientId. In a Javascript function I tried to hide a panel as follows: function ChangePanel() { document.getElementById("<%=Panel1.ClientID %>").style.display =
14
2343
by: Julesh | last post by:
Hello, I am new to ASP and am trying to make some changes to some ASP 3.0 code I have inherited. I have a number of ASP pages with VBS as the base language, on each of these pages I have successfully included a piece of VBS code that produces output in a table cell by using: <!--#include file="showAnswers.inc" -->
1
1956
exoskeleton
by: exoskeleton | last post by:
Hi..to all expert...i have this situation .. i cant get the value of the file field in the other page..im using a simple javascript like this... example: // this is page1.php <head> function send() { var ajaxRequest;
2
2218
coolv
by: coolv | last post by:
Hello I have problem in my page that the dropdown box is not displaying data according to selection of first dropdown.Please help me. Below is my code. thanks.............. <?php session_start(); if (!isset($_SESSION)) {
3
3040
by: knkk | last post by:
I am trying to include this code in the footer.template files of all blog templates: <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try{ var pageTracker = _gat._getTracker("UA-xxxxxx-x");...
3
5890
omerbutt
by: omerbutt | last post by:
hi there i am trying to run the lightbox and a slider on a single page the light box is working allrigh but when i try to include the slider in the same page it generates error because i have to include the jquery.js file to run it .i think it is a problem with the order of the file include. the error which i receive is here and on the prototype.js which is included for the lightbox i am stucked please any one here error: my code is...
0
9484
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10350
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9957
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7505
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.