By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,506 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

Cannot use includes

P: n/a
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,

--
Peter Afonin
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In article <pc********************@speakeasy.net>, Peter says...
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.

--
Hywel I do not eat quiche
http://kibo.org.uk/
http://kibo.org.uk/mfaq.php
Jul 23 '05 #2

P: n/a
Yes, you're correct. Thank you, Hywel, it works now.

Peter

"Hywel" <hy**********@hotmail.com> wrote in message
news:MP************************@news.individual.ne t...
In article <pc********************@speakeasy.net>, Peter says...
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.

--
Hywel I do not eat quiche
http://kibo.org.uk/
http://kibo.org.uk/mfaq.php

Jul 23 '05 #3

P: n/a
JRS: In article <pc********************@speakeasy.net>, seen in
news:comp.lang.javascript, Peter <pv*@speakeasy.net> posted at Sat, 8
May 2004 14:44:47 :
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.

--
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.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.