Include Javascript multiple

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

    Include Javascript multiple

    Hi,

    Here is my problem :

    Here is my first HTML file including a js :
    <script language="JavaS cript"
    src="http://www.toto.com/monjs.js"></script>

    In my "monjs.js" :

    document.write( '<table cellpadding="0" cellspacing="0" border="1"
    style="width:25 0; color: #000000">');
    document.write( '<tr>');
    document.write( '<td style="width: 250;">');
    document.write( "line1");
    document.write( '</td>');
    document.write( '</tr>');
    document.write( '<tr>');
    document.write( '<td style="width: 250;">');
    document.write( "<s" + "cript language='javas cript'
    type='text/javascript'
    src='http://www.toto.com/monjs2.js'></s" + "cript>");
    document.write( '</td>');
    document.write( '</tr>');
    document.write( '<tr>');
    document.write( '<td style="width: 250;">');
    document.write( "line3");
    document.write( '</td>');
    document.write( '</tr>');
    document.write( '</table>');

    In my "monjs2.js" :
    document.write( 'line2');

    See the result : I've got no text in my line 2 of my table. "line2" is
    written after the table.

    Thanx a lot for any idea...

    @+
    David
  • McKirahan

    #2
    Re: Include Javascript multiple

    "brainofj" <david_banget@y ahoo.fr> wrote in message
    news:40caf4a8.0 411091052.1b4e5 468@posting.goo gle.com...[color=blue]
    > Hi,
    >
    > Here is my problem :
    >
    > Here is my first HTML file including a js :
    > <script language="JavaS cript"
    > src="http://www.toto.com/monjs.js"></script>
    >
    > In my "monjs.js" :
    >
    > document.write( '<table cellpadding="0" cellspacing="0" border="1"
    > style="width:25 0; color: #000000">');
    > document.write( '<tr>');
    > document.write( '<td style="width: 250;">');
    > document.write( "line1");
    > document.write( '</td>');
    > document.write( '</tr>');
    > document.write( '<tr>');
    > document.write( '<td style="width: 250;">');
    > document.write( "<s" + "cript language='javas cript'
    > type='text/javascript'
    > src='http://www.toto.com/monjs2.js'></s" + "cript>");
    > document.write( '</td>');
    > document.write( '</tr>');
    > document.write( '<tr>');
    > document.write( '<td style="width: 250;">');
    > document.write( "line3");
    > document.write( '</td>');
    > document.write( '</tr>');
    > document.write( '</table>');
    >
    > In my "monjs2.js" :
    > document.write( 'line2');
    >
    > See the result : I've got no text in my line 2 of my table. "line2" is
    > written after the table.
    >
    > Thanx a lot for any idea...
    >
    > @+
    > David[/color]

    Try:

    <script type="text/javascript" src="http://www.toto.com/monjs1.js"></script>
    <script type="text/javascript" src="http://www.toto.com/monjs2.js"></script>
    <script type="text/javascript" src="http://www.toto.com/monjs3.js"></script>

    Where "monjs1.js" =

    document.write( '<table cellpadding="0" cellspacing="0" border="1"
    style="width:25 0; color: #000000">');
    document.write( '<tr>');
    document.write( '<td style="width: 250;">');
    document.write( "line1");
    document.write( '</td>');
    document.write( '</tr>');
    document.write( '<tr>');
    document.write( '<td style="width: 250;">');

    Where "monjs2.js" =

    document.write( 'line2');


    Where "monjs3.js" =

    document.write( '</td>');
    document.write( '</tr>');
    document.write( '<tr>');
    document.write( '<td style="width: 250;">');
    document.write( "line3");
    document.write( '</td>');
    document.write( '</tr>');
    document.write( '</table>');


    Comment

    • Hal Rosser

      #3
      Re: Include Javascript multiple


      "brainofj" <david_banget@y ahoo.fr> wrote in message
      news:40caf4a8.0 411091052.1b4e5 468@posting.goo gle.com...[color=blue]
      >
      > document.write( '<table cellpadding="0" cellspacing="0" border="1"
      > style="width:25 0; color: #000000">');[/color]
      *****Hold it right there****
      ******The semicolon after the 250 makes
      ******* js think the end of statement has arrived
      ********* easy mistake to make -
      ********* maybe put the styles into a css file of its own
      *************** *************** *************** ****



      ---
      Outgoing mail is certified Virus Free.
      Checked by AVG anti-virus system (http://www.grisoft.com).
      Version: 6.0.788 / Virus Database: 533 - Release Date: 11/1/2004


      Comment

      • Randy Webb

        #4
        Re: Include Javascript multiple

        Hal Rosser wrote:
        [color=blue]
        > "brainofj" <david_banget@y ahoo.fr> wrote in message
        > news:40caf4a8.0 411091052.1b4e5 468@posting.goo gle.com...
        >[color=green]
        >>document.writ e('<table cellpadding="0" cellspacing="0" border="1"
        >>style="width: 250; color: #000000">');[/color]
        >
        > *****Hold it right there****
        > ******The semicolon after the 250 makes
        > ******* js think the end of statement has arrived[/color]

        No it doesn't.
        [color=blue]
        > ********* easy mistake to make -
        > ********* maybe put the styles into a css file of its own
        > *************** *************** *************** ****[/color]

        Now, you stop right there. Your answer is about as wrong as wrong can get.

        Go ahead, try it. Put it in a sample page. It works as written as long
        as its one line. Stop giving garbage answers and confusing people who
        are here to try to learn. At a minimum, test your answers. I did.


        --
        Randy
        comp.lang.javas cript FAQ - http://jibbering.com/faq
        Answer:It destroys the order of the conversation
        Question: Why?
        Answer: Top-Posting.
        Question: Whats the most annoying thing on Usenet?

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: Include Javascript multiple

          Hal Rosser wrote:
          [color=blue]
          > "brainofj" <david_banget@y ahoo.fr> wrote [...][color=green]
          >> document.write( '<table cellpadding="0" cellspacing="0" border="1"
          >> style="width:25 0; color: #000000">');[/color]
          > *****Hold it right there****
          > ******The semicolon after the 250 makes
          > ******* js think the end of statement has arrived[/color]

          That statement is as nonsensical as your posting style is. No working
          script engine would parse the ";" within a string literal as a statement
          delimiter.

          The real reason is that the UA parses elements, not tags; therefore writing
          the start tag of an element without the matching end tag is likely to cause
          problems. More, consecutive document.write( ) calls are inefficient,
          instead the lines should be concatenated -- preferably using an Array
          literal and Array.prototype .join() rather than several "+" operations,
          if it does not need to run with non-ECMAScript 3 compliant engines --,
          then written with *one* document.write( ) call:

          document.write([
          'foo',
          'bar'
          ].join(''));

          To make the generated source code more legible, one could write

          document.write([
          'foo',
          'bar'
          ].join('\n'));


          PointedEars
          --
          I can't find the OK button anywhere on my keyboard!!!

          Comment

          Working...