Include Javascript multiple

B

brainofj

Hi,

Here is my problem :

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

In my "monjs.js" :

document.write('<table cellpadding="0" cellspacing="0" border="1"
style="width:250; 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='javascript'
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
 
M

McKirahan

brainofj said:
Hi,

Here is my problem :

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

In my "monjs.js" :

document.write('<table cellpadding="0" cellspacing="0" border="1"
style="width:250; 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='javascript'
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

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:250; 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>');
 
H

Hal Rosser

brainofj said:
document.write('<table cellpadding="0" cellspacing="0" border="1"
style="width:250; color: #000000">');
*****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
*************************************************
 
R

Randy Webb

Hal said:
*****Hold it right there****
******The semicolon after the 250 makes
******* js think the end of statement has arrived

No it doesn't.
********* easy mistake to make -
********* maybe put the styles into a css file of its own
*************************************************

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.javascript 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?
 
T

Thomas 'PointedEars' Lahn

Hal said:
*****Hold it right there****
******The semicolon after the 250 makes
******* js think the end of statement has arrived

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top