DHTML trubbs

W

Wilier

Guest
Im trying to runs 2 DHTML scripts on the same page, one sits in the <head> tags, and one in the <body>.

Now, the one in <body> runs fine on its own, its this one. But as soon as I add this is makes the scrolling screen sieze up!!

The code looks like
this

Youll have to view the source. :p.
Any ideas?
 
J

Jonty

Guest
Hi Wilier

I believe the problem is that both scripts are trying to execute 'onload', which can cause problems. I think, however, this will sort your problems . . .

  1. In your scroller script, go down to the last line of code and delete it.
    Code:
    [b]The original code ...[/b]
    
    else if (ns4)
    document.nscontainer.document.nscontent.visibility="show"
    }
    window.onload=getcontent_height
    </script>
    
    [b]... becomes this ...[/b]
    
    else if (ns4)
    document.nscontainer.document.nscontent.visibility="show"
    }
    </script>
  2. Next open the file 'style.js' in Wordpad or equivalent (not Notepad) and scroll to the following section, adding the line below.
    Code:
    [b]The original code ...[/b]
    
    //** DO NOT EDIT THIS ****************************************
    stySTR+='//--></style>';d.write(stySTR);}
    function genericOnloadFunction() {
    //*************************************************************
    //****##### USE THIS SPACE TO DEFINE ONLOAD FUNCTIONS #####****
    
    [b]... becomes this ...[/b]
    
    //** DO NOT EDIT THIS ****************************************
    stySTR+='//--></style>';d.write(stySTR);}
    function genericOnloadFunction() {
    //*************************************************************
    //****##### USE THIS SPACE TO DEFINE ONLOAD FUNCTIONS #####****
    window.onload = getcontent_height;
I'm not too sure whether this will work with the scroller functions being in the <body>, but I'll guess we'll soon find out :D

If you're still having trouble then please feel free to post again.

Kind Regards
 
W

Wilier

Guest
Ive tried it Jonty, but it dosnt seem to make a difference, unless......when I opened style.js in wordpad, and saved it, it said about it being text onle and losing all formatting, will this make a difference?

here is the actual page. index
 
J

Jonty

Guest
The formatting Wordpad refers to is the font type and size etc, and doesn't make any difference to the actual code itself (the only reason you cannot open 'style.js' in Notepad is that in this instance it cannot understand the line breaks used).

If you don't mind waiting until this evening, then I will cobble together a simple page with both scripts on it. I have a feeling we need only write a simple function which contains all onload items for any script we choose to use. Either that, or just use a different scroller or menu :) (although, that said, most will use onload events, but at least their code would be easier to play with).

Sorry I cannot be of more immediate use
 
J

Jonty

Guest
Just out of interest, try the original solution but utilise this code instead for the second modification

Code:
//** DO NOT EDIT THIS ****************************************
stySTR+='//--></style>';d.write(stySTR);}
function genericOnloadFunction() {
//*************************************************************
//****##### USE THIS SPACE TO DEFINE ONLOAD FUNCTIONS #####****
getcontent_height();
It probably still won't work, but you never know, the sun is shining, and I'm feeling lucky :D

Kind Regards
 
W

Wilier

Guest
nah, that didnt work either bud.

I can wait as long as you need mate, no problem.
 
J

Jonty

Guest
Hi Wilier

After looking at the scripts and the source I found it's actually nothing to do with how the scripts are loaded, so my apologies on that part. What I did find was that it's your HTML source which is corrupted and hence causing you the problems. Specifically, it's the table below the <body> tag that is causing the problems . . .
Code:
<body bgcolor="#cccccc" text="#666666" link="#6600FF" vlink="#FF0033"  >

[u]Problem Code[/u]
<td valign=top >
			<table border=2 cellpadding=3 cellspacing=0 align="center" width="50%"> 
			<tr>
			<td align=center valign=top bgcolor="#66ccff"></td>
			</tr>
[u]End Problem Code[/u]





</p>
Delete the emboldened code and everything should work correctly. You should note, however, that this code is hideous fragmented :( I know it's nor your fault, though.

Kind Regards
 
W

Wilier

Guest
Jonty, you are my hero. Cheers m8y. Couple of other things if youve got a mo, in amongst lounging on the beach and looking at ultra expensive PC parts ;)

How can I get the scrolling table back into the middle of the page?

On the top menu, on the drop down menu's, how would I move the<< next to archive? I cant seem to find it in the code.

I know its all a bit messy, but thats cos Im not real good at this HTML stuff. :(
 
J

Jonty

Guest
Hi Wilier

I started looking at the code and by the time I had finished I had ended up rewriting for you! Here's the new source:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
  <title>Wilier's Wonderfull Webby</title>
  <meta content="charset=utf-8; text/html;" http-equiv="Content-Type">
  <style type="text/css">
    A, A:Visited, A:Linked, A:Hover { background-color:transparent; color:#000000; }
  </style>

  <!--
  Top Navigational Bar III v3.4.1.1b (c) [email]cake@brothercake.net[/email]
  For full source code visit [url]http://www.dynamicdrive.com[/url]
  -->

  <script src="sniffer.js" type="text/javascript"></script>
  <script src="custom.js" type="text/javascript"></script>
  <script src="style.js" type="text/javascript"></script>
</head>

<body style="background-color:#cccccc; color:#666666; margin-top:50px;">

<center>

<div>
  [url="#"]Down[/url]
  [url="#"]Up[/url] 
  [url="#"]Stop[/url]
  [url="#"]Top[/url]
</div>

<div id="container" style="border:2px ridge #FFFFFF; height:300px; overflow:hidden; position:relative; width:600px;">
  <div align="left" id="content" style="left:0px; position:absolute; top:0px; width:600px;">



[i]update 13 March 2003 10.16[/i]
<hr>
Today is my 32nd birthday. Please send all pressies, gifts, cards etc to the usual address.
Thanks.
<hr>

[i]update 10 March 2003 04.41[/i]
<hr>
Well if Im not one pissed off puppy.
 Since Im on nights tnite, I thought I would bring
my friends PC [which Im sposed to be repairing ;o)] and wack CS onto it so I could have a game
in the wee small hours. Got to work, relly quiet, not much to do. PC set-up in my office, modem
set-up and installed, grabs the CD's and.......shock.......horror, Ive grabbed the wrong fecking
CD, Ive brought Opposing Force instead of Half-Life. Noooooooooooooooo. Im Gutted with a capital
G. :o(
<hr>

[i]update 07 March 2003 16.00[/i]
<hr>
First week in the new job has gone well, real well actually. Ive been quite busy, and the
threats are that it will get even busier, but hey-ho.
 As far as the mini-case thingy goes,
Ive not really done anything about that, times been a bit tight, but Im still excited about
having a go, in fact, Ive come up with a super plan for a different design, watch this space.

Ive been making enquiries about how to run the games servers and a DHCP for the next LAN,
I posted a thread on [url="http://forums.barrysworld.com/showthread.php?amp;threadid=49872"]Barrysworld[/url]
asking for a bit of advice and Will PM'd me offering to come down and run the servers for
us.......from Edinburgh. Now thats friendly. Also, means Laz has no fecking excuse to not
turn up ;O). As a side note, I won an auction on eBay for a Dell dual slot1 mobo, for
&pound;10.50. Shweet, add to that a couple of Celeron 450 CPU's that one of the chaps from
the ZhG has said I could have, and we have the basis of a machine that [i]should[/i] run
at least 5 dedicated servers, all by itself. Cool or what.
 Bad news is that Im covering
shifts on Sunday night. Booooooooo
<hr>



  </div>
</div>

</center>

<!--
Manual Scroller (c) Dynamic Drive 2001
For full source code visit [url]http://www.dynamicdrive.com[/url]
-->

<script type="text/javascript">
var speed = 4
var iens6 = document.all||document.getElementById;

if (iens6)
{
  var crossobj=document.getElementById? document.getElementById("content") : document.all.content
  var contentheight=crossobj.offsetHeight
}

function movedown()
{
  if (window.moveupvar) clearTimeout(moveupvar)
  if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100))
  crossobj.style.top=parseInt(crossobj.style.top)-speed
  movedownvar=setTimeout("movedown()",100)
}

function moveup()
{
  if (window.movedownvar) clearTimeout(movedownvar)
  if (iens6&&parseInt(crossobj.style.top)<=0)
  crossobj.style.top=parseInt(crossobj.style.top)+speed
  moveupvar=setTimeout("moveup()",100)
}

function stopscroll()
{
  if (window.moveupvar) clearTimeout(moveupvar)
  if (window.movedownvar) clearTimeout(movedownvar)
}

function movetop()
{
  stopscroll()
  if (iens6)
  crossobj.style.top=0
}

function getcontent_height()
{
  if (iens6)
  contentheight=crossobj.offsetHeight
}
</script>

<script src="menu.js" type="text/javascript"></script>

</body>
</html>
It still utilises a lot of old standards, so it's nothing too radically different from the old code. However, not only is it now tidy, but it is also HTML 4.01 complaint (meaning you can wear this logo with pride ;)).

As requested, the content is now centered, too.

With regards the menu position, open up the file 'custom.js' and go to line 112 (Ctrl+G in Notepad) which looks like:
Code:
defineChildmenuProperties(102,"left","center",0,-20,"filter:progid:DXImageTransform.Microsoft.Wheel(duration=0.3,spokes=20)");
Change "left" to "right". Repeat this for line 158 . . .
Code:
defineChildmenuProperties(102,"left","center",0,-20,"filter:progid:DXImageTransform.Microsoft.Wheel(duration=0.3,spokes=20)");
. . . and line 168 . . .
Code:
defineChildmenuProperties(102,"left","center",0,-20,"filter:progid:DXImageTransform.Microsoft.Wheel(duration=0.3,spokes=20)");
If you'd rather the menus stay where they were and just change the arrows, simply search the unaltered 'custom.js' for "&lt;&lt" and replace with "&gt;&gt;".

I think that's about it. Oh, one minor thing, NS4 is no longer supported in the above script because of the changes I made. But don't worry, very very few people use this browser any more and those which do should upgrade!

Hope this helps. If you have any questions, please feel free to ask. If you're ever feeling flush, then I'd be happy to create a website for you through my design company, Amaurea Design, which I am in the process of establishing. Not only do you get a bespoke, hand-coded, cutting-edge website, but every penny after our extremely low costs have been covered goes directly to various charities around the world. So not only do you get a groovy site, you also get to rest safe in the knowledge that your money has also benefited some of the neediest people in the world.

Anyway, sorry, shouldn't plug my own things!

Kind Regards
 
W

Wilier

Guest
Once again Jonty, you have surpassed all expectation. Thanks so much for your help, I really appreciate that. :D

The site, whilst lacking decent content ;)) at least looks better now, cheers mate.
 

Users who are viewing this thread

Top Bottom