Cannot use includes

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

    Cannot use includes

    Hello:

    I've just asked a question about the includes, and I appreciate your help
    very much.

    However, this still doesn't work for me. What am I doing wrong?

    I have a script that should go tho the <HEAD> tag:

    <SCRIPT language="JavaS cript">
    // <!-- Main
    function banners()
    {
    this[1]="http://www.url.com";
    this[2]="banners/bann1.gif";
    this[3]="http://www.url.com";
    this[4]="banners/bann2.gif";
    this[5]="http://www.url.com";
    this[6]="banners/bann3.gif";

    if ((navigator.app Name == "Netscape") &&
    (parseInt(navig ator.appVersion .substring(0,1) ) < 3)) { return(' '); }
    var j=(new Date()).getSeco nds() % 3;
    document.write( '<a href=' + this[2*j+1] + ' target=blank><i mg src=' +
    this[2*j+2] + ' border=0 width=520 height=60></a>');
    return(' ');
    }
    // -->
    </SCRIPT>

    This script goes to <BODY>:

    <SCRIPT language="JavaS cript">
    // <!-- Main
    banners();
    // -->
    </SCRIPT>

    When I insert this script to the page itself - it works great. However, if I
    put the HEAD protion of the script into a file banners.js, put this file
    into the same directory as the page itself, then add this line to the <HEAD>
    tag (or <BODY>, doesn't work anyway):

    <script language="javas cript" type="text/javascript"
    src="banners.js "></script>

    - nothing works.

    What's wrong?

    I would appreciate your advice.

    Thank you,

    --
    Peter Afonin


  • Hywel

    #2
    Re: Cannot use includes

    In article <pcacnSPUKt5ZyQ Dd38DK-w@speakeasy.net >, Peter says...[color=blue]
    > Hello:
    >
    > I've just asked a question about the includes, and I appreciate your help
    > very much.
    >
    > However, this still doesn't work for me. What am I doing wrong?
    >
    > I have a script that should go tho the <HEAD> tag:
    >[/color]
    [color=blue]
    > When I insert this script to the page itself - it works great. However, if I
    > put the HEAD protion of the script into a file banners.js, put this file
    > into the same directory as the page itself, then add this line to the <HEAD>
    > tag (or <BODY>, doesn't work anyway):
    >
    > <script language="javas cript" type="text/javascript"
    > src="banners.js "></script>
    >
    > - nothing works.
    >
    > What's wrong?[/color]

    Are you leaving the <script> and </script> tags in your included file?
    If you are, don't.

    --
    Hywel I do not eat quiche


    Comment

    • Peter

      #3
      Re: Cannot use includes

      Yes, you're correct. Thank you, Hywel, it works now.

      Peter

      "Hywel" <hyweljenkins@h otmail.com> wrote in message
      news:MPG.1b0773 5eee1dfa749896c 7@news.individu al.net...[color=blue]
      > In article <pcacnSPUKt5ZyQ Dd38DK-w@speakeasy.net >, Peter says...[color=green]
      > > Hello:
      > >
      > > I've just asked a question about the includes, and I appreciate your[/color][/color]
      help[color=blue][color=green]
      > > very much.
      > >
      > > However, this still doesn't work for me. What am I doing wrong?
      > >
      > > I have a script that should go tho the <HEAD> tag:
      > >[/color]
      >[color=green]
      > > When I insert this script to the page itself - it works great. However,[/color][/color]
      if I[color=blue][color=green]
      > > put the HEAD protion of the script into a file banners.js, put this file
      > > into the same directory as the page itself, then add this line to the[/color][/color]
      <HEAD>[color=blue][color=green]
      > > tag (or <BODY>, doesn't work anyway):
      > >
      > > <script language="javas cript" type="text/javascript"
      > > src="banners.js "></script>
      > >
      > > - nothing works.
      > >
      > > What's wrong?[/color]
      >
      > Are you leaving the <script> and </script> tags in your included file?
      > If you are, don't.
      >
      > --
      > Hywel I do not eat quiche
      > http://kibo.org.uk/
      > http://kibo.org.uk/mfaq.php[/color]


      Comment

      • Dr John Stockton

        #4
        Re: Cannot use includes

        JRS: In article <pcacnSPUKt5ZyQ Dd38DK-w@speakeasy.net >, seen in
        news:comp.lang. javascript, Peter <pva@speakeasy. net> posted at Sat, 8
        May 2004 14:44:47 :
        [color=blue]
        >I've just asked a question about the includes, and I appreciate your help
        >very much.
        >
        >However, this still doesn't work for me. What am I doing wrong?
        >
        >I have a script that should go tho the <HEAD> tag:
        >
        ><SCRIPT language="JavaS cript">
        >// <!-- Main
        >function banners()
        >{
        >this[1]="http://www.url.com";
        >this[2]="banners/bann1.gif";
        >this[3]="http://www.url.com";
        >this[4]="banners/bann2.gif";
        >this[5]="http://www.url.com";
        >this[6]="banners/bann3.gif";
        >
        >if ((navigator.app Name == "Netscape") &&
        >(parseInt(navi gator.appVersio n.substring(0,1 )) < 3)) { return(' '); }
        >var j=(new Date()).getSeco nds() % 3;
        >document.write ('<a href=' + this[2*j+1] + ' target=blank><i mg src=' +
        >this[2*j+2] + ' border=0 width=520 height=60></a>');
        >return(' ');
        >}
        >// -->
        ></SCRIPT>
        >
        >This script goes to <BODY>:
        >
        ><SCRIPT language="JavaS cript">
        >// <!-- Main
        >banners();
        >// -->
        ></SCRIPT>
        >
        >When I insert this script to the page itself - it works great. However, if I
        >put the HEAD protion of the script into a file banners.js, put this file
        >into the same directory as the page itself, then add this line to the <HEAD>
        >tag (or <BODY>, doesn't work anyway):
        >
        > <script language="javas cript" type="text/javascript"
        >src="banners.j s"></script>
        >
        >- nothing works.
        >
        >What's wrong?
        >
        >I would appreciate your advice.[/color]

        Obviously you do not understand what is happening. In that case, you
        should simplify things until you do understand; it reduces the number of
        possibilities.

        Your code manifestly envisages differences between browsers; but
        you do not say what browser you used for the failing test.


        Use the line var Test = 7 as the *sole* contents
        of your include file; and alert(Test) as the
        *sole* script in a *minimal* HTML page.

        If you can't get that to work, even after reading <URL:http://www.merlyn
        ..demon.co.uk/js-nclds.htm#OV>, then post the entire contents of both
        *minimal* files here.


        <SCRIPT language="JavaS cript">
        should be
        <script type="text/javascript">

        Indent your code so that its structure is clear, and ensure that it
        neither is nor appears to be line-wrapped by your news software.

        --
        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
        <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
        <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
        <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

        Comment

        Working...