User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 402,706 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,456 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

I hate Firefox!

Join Date: Jun 2006
Location: UK (Bristol)
Posts: 225
Reputation: Mushy-pea is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 1
Mushy-pea's Avatar
Mushy-pea Mushy-pea is offline Offline
Posting Whiz in Training

I love Firefox!

  #4  
Feb 11th, 2007
OK, I've had a longer look at your code this time. First, user defined functions (i.e. function name () { } ) should all be inside a <script> tag within the document <head>. I've re - formatted your code so the semicolons are in the right places as well:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Welcome To Reptile Planet">
<meta name="keywords"
content="Reptiles">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title> Credit Screen</title>
<script type="text/javascript">
function initialize() {
startit();
}
function scrollwindow() {
if (document.all)
temp=document.body.scrollTop;
else
temp=window.pageYOffset;
if (alt==0)
alt=1;
else
alt=0;
if (alt==0)
curpos1=temp;
else
curpos2=temp;
if (curpos1!=curpos2) {
if (document.all)
currentpos=document.body.scrollTop+1;
else
currentpos=window.pageYOffset+1;
window.scroll(0,currentpos);
}
else{
currentpos=0;
window.scroll(0,currentpos);
}
}
function startit() {
setInterval("scrollwindow()",2);
}
</script>
</head>

<body background="http://i14.photobucket.com/albums/a345/Instar/escher_background.gif">
<script type="text/javascript">
var currentpos=0;
alt=1;
curpos1=0;
curpos2=-1;

/*This script block will be run when the page has loaded anyway, so no need to use the window.onload handler*/
initialise();
</script>

<p>&nbsp;</p>
<p>&nbsp;</p>

<p align="center"><img src="http://i14.photobucket.com/albums/a345/Instar/rp2-1.jpg" width="371" height="35"
alt="logo (5979"><br>
<small><font face="Verdana">Credits Page</font></small></p>

<p align="left"><strong><font face="Verdana">~Main credits~</font></strong></p>

<p align="left"><font face="Verdana"><strong>Creator and main operator: </strong>Inny</font></p>

<p align="left"><font face="Verdana"><strong>Co-Admin: </strong>Gecko Girl</font></p>

<p align="left"><font face="Verdana"><strong>Design: </strong> Inny</font></p>

<p align="left"><font face="Verdana"><strong> Main Affiliate: </strong>TheHerpHouse.Com</font></p>

<p align="left"><font face="Verdana"><strong>Address: </strong>http://www.theherphouse.com/</font></p>

<p align="left"><font face="Verdana"><strong>Banner Creator: </strong> Scaleman</font></p>

<p align="left"><strong><font face="Verdana">~Additional credits~</font></strong></p>

<p align="left"><font face="Verdana"><strong>Ambassador: </strong>Dragon</font></p>

<p align="left"><font face="Verdana"><strong>Footer Banner Creator: </strong>Poppette</font></p>

<p><strong><font face="Verdana">~Misc credits~</font></strong></p>

<p><font face="Verdana"><strong>Web host provider: </strong>WWW.Forumer.com</font></p>
<p><center><image src="http://i14.photobucket.com/albums/a345/Instar/spashapic.jpg"></img></center></p>
<p>&nbsp;</p>
</body>
</html>

A few points to mention here:

1. The <!DOCTYPE> definition needs to be at the top, just before <html>.
2. The var keyword has the effect of making variables declared inside a function with it, local to that function. Using it in a <script> block in the document body has (I think) no effect.
3. It is OK to use
if (test == 0)
document.write("Some code run");
where only one line is to be run as a result of the condition. But, it can make your code look a bit unclear sometimes. Consider using
if (test == 0) {
document.write("Some code run");
}
more.
4. Most browsers are able to show you errors in javascript. In IE look in Tools > Internet options > general and turn on script debugging to get error messages like from a proper compiler. In other browsers look for an error console in the menus (Opera has one).
5. Use <script type="text/javascript"> rather than the language attribute you were using. It's the standard method and more likely to work on all browsers.

Hope this helps.

Steven.
Last edited by Mushy-pea : Feb 11th, 2007 at 8:59 am.
Hello, you're through to Steven on the BT Business technical help desk. Could I take your broadband telephone number please?
Reply With Quote  
All times are GMT -4. The time now is 6:13 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC