problem with Javascript code from Include

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Strazzeri

    #1

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

  • SCDeveloper

    #2
    Re: problem with Javascript code from Include

    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


    Comment

    • Tony

      #3
      Re: problem with Javascript code from Include

      "Tony Strazzeri" <strazz@my-Deja.com> wrote in message
      news:1116227904 .147012.101250@ g43g2000cwa.goo glegroups.com.. .[color=blue]
      > 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.[/color]

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


      Comment

      • Tony Strazzeri

        #4
        Re: problem with Javascript code from Include

        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.

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: problem with Javascript code from Include

          [stripped X-Post to microsoft.publi c.frontpage
          since no such group exists on this server]

          Tony Strazzeri wrote:
          [color=blue]
          > 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[/color]

          Yes, it *seems to be* that way. However, it *is* not so.
          [color=blue]
          > <script src="./scripts/gen_email.js" type="text/javascript"></script>[/color]
          ^^ ^^^^^^^^^^^^
          If you would care to compare with the original version:

          | <script src="\scripts/email_addy.js"
          ^ ^^^^^^^^^^
          | type="text/javascript"></script>
          [color=blue]
          > Funny though...[/color]

          Not at all.
          [color=blue]
          > I am sure I had already tried that.[/color]

          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.
          [color=blue]
          > 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.[/color]

          Are you also going to tell us what you are going to do next week?


          PointedEars

          Comment

          • Randy Webb

            #6
            Re: problem with Javascript code from Include

            Thomas 'PointedEars' Lahn wrote:[color=blue]
            > [stripped X-Post to microsoft.publi c.frontpage
            > since no such group exists on this server][/color]

            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

            Comment

            Working...