Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code no longer works - after moved to .js file

Status
Not open for further replies.

schedboy

Programmer
Nov 8, 2006
3
GB
Hi all,

I had this code working:



bannerQuotes = new Array("img/border_bot_left.gif","img/border_top_left.gif","img/border_top_right.gif","img/border_top_left.gif");

startAt = 0;
totalElements = bannerQuotes.length;


function rotate()
{
if(document.images)
{
startAt++;
if(startAt==totalElements)
{ startAt=0;}

document.adBanner.src=bannerQuotes[startAt];
setTimeout("rotate()",3*1000);
}
}



Fine if included in the head tags of my HTML doc, and calling rotate() from the body onload event.

However, now I've cut it out and placed it externally - it no longer works...

I've got:

<script src="/jscript/amsJScod.js" language="Javascript" type="text/javascript">
</script>

In my header but am having no luck

Thanks

Sched
 
Hi BabJeff,

The only thing in the .js file is what you see in my first post.

any other ideas?????

Thanks

Sched
 
Hi all,

Cheers for your replies.
I have fixed the problem, it was with the path of the .js file:

<script src="/jscript/amsJScod.js" language="Javascript" type="text/javascript">
</script>

Once I removed the first / from the path, it worked fine! I guess I'll have to put it back when I upload to the server?????

Thanks

Sched
 
If you put it, the script will reference an absolute path. If not, the path will be relative, and I think that's what you're looking for, so I'd not change it.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top