Cannot use includes

P

Peter

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="JavaScript">
// <!-- 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.appName == "Netscape") &&
(parseInt(navigator.appVersion.substring(0,1)) < 3)) { return(' '); }
var j=(new Date()).getSeconds() % 3;
document.write('<a href=' + this[2*j+1] + ' target=blank><img src=' +
this[2*j+2] + ' border=0 width=520 height=60></a>');
return(' ');
}
// -->
</SCRIPT>

This script goes to <BODY>:

<SCRIPT language="JavaScript">
// <!-- 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="javascript" type="text/javascript"
src="banners.js"></script>

- nothing works.

What's wrong?

I would appreciate your advice.

Thank you,
 
H

Hywel

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:
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="javascript" type="text/javascript"
src="banners.js"></script>

- nothing works.

What's wrong?

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

Dr John Stockton

JRS: In article <[email protected]>, seen in
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="JavaScript">
// <!-- 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.appName == "Netscape") &&
(parseInt(navigator.appVersion.substring(0,1)) < 3)) { return(' '); }
var j=(new Date()).getSeconds() % 3;
document.write('<a href=' + this[2*j+1] + ' target=blank><img src=' +
this[2*j+2] + ' border=0 width=520 height=60></a>');
return(' ');
}
// -->
</SCRIPT>

This script goes to <BODY>:

<SCRIPT language="JavaScript">
// <!-- 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="javascript" type="text/javascript"
src="banners.js"></script>

- nothing works.

What's wrong?

I would appreciate your advice.

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="JavaScript">
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.
 

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
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top