Solved

Run two javascript .js files on same web page

Posted on 2008-06-16
24
764 Views
Last Modified: 2008-06-17
Hi Guys

I have two scripts, both of which run perfectly when used individually veither inside the body or in the header

<Script Language="javascript" SRC="alltxt"></Script>
<Script Language="javascript" SRC="alltxt"></Script>

If both of them are there then then only the last one loaded works.
The code garnered from other sites and shown below cause neither to work.

I've tried all afternoon and getting tired of so-called solutions that don't work. Anyone have a clue about this one please?
<script language="javascript">

	function 1(){

		src="sidemenu.js";

	}

	function 2(){

		src="alttxt.js";

		}

	function LoadFunction(){

		function 1

		function 2

	}

</script>
 

	 

</HEAD>

	<body onload="LoadFunctions()" background="images\WebFront.jpg">

Open in new window

0
Comment
Question by:gjpitt
  • 11
  • 8
  • 5
24 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 21795085
Best would be to delete this question and open a new one with your real world script tags and your real world scripts. Then you can moan about so called "questions" ;-)
0
 

Author Comment

by:gjpitt
ID: 21795141
Who is moaning about so-called questions. So-called SOLUTIONS Yes! from other less expert sites. Yours is the first bad comment I have ever had frm this site.

As regards your comments about using real scripts etc. I have and if you are unable to see that then perhaps your rank of genius is not quite accurate.

I have to use javascript at times, reluctantly because it does some nice things but I'm not an expert.
So, if you DO know the answer perhaps you would care to share it with me.
Thank you
0
 

Author Comment

by:gjpitt
ID: 21795165
BTW: The code snippet is what is in my page at the moment the piece in the text of the question should perhaps read

<Script Language="javascript" SRC="alltxt"></Script>
<Script Language="javascript" SRC="sidemenu"></Script>
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 21795202
Cheerio!
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 21795522
http:Q_23488797.html

So if you are serious about this question that please do the effort to provide the correct lines from your source code.
Before discussing with me my ranking better simply copy your <script> lines and copy your JavaScript statements from the html page as they are actualy there. Best would be to post the complette html page source.

Then for sure I can explain to you what you how to change in your code to get it working. Beside me there a many experts here that can do the same because your problem is a typical beginner problem. No offense...
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21795603
One thing that I have encountered is when I have mixed "script" tags, by that I mean, one (or more) like this:

<script type='text/javascript" ...>

and one (or more) like this:

<script language='javascript"...>

Might you be running into this kind of issue?
0
 

Author Comment

by:gjpitt
ID: 21795650
Hi HonorGod

These are the lines I did use successfully.

<Script Language="javascript" SRC="alltxt.js"></Script>

It is a case of either/or but not both together:)

<Script Language="javascript" SRC="sidemenu.js"></Script>

Therefore both scripts work individually but not together. Other sites came up with various solutions involving placing both src bit into a script function and then calling the function in the body onload line. However, as you can see from my code snippet - it don't work:)

I suspect that it is a lack of grammatical correctness as it usually is with javascript but I need help.
Thanks
Graham
0
 

Author Comment

by:gjpitt
ID: 21795738
Hi Zvonko

The rest of the page is mainly VBScript and highly repetitive and does not impact on the problem. IT is simply a case of getting these two js files to work together. I apologise for the typos in my first bit of this question, but I had moved on from there in my attempts to find a solution outside of EE. The code snippet is what is actually on the page at the  moment - burning a hole somewhere no doubt:)

Cheers
Graham
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 21795782
Can you please look at the browser page html page source and copy the generated html page source here to your question please.
0
 

Author Comment

by:gjpitt
ID: 21795807
Here goes:)

Graham
<HTML>

  <HEAD>

		<title>Computers For Charity Welcome</title>

		<meta name="description" content="Computers for Charity collects from industry, refurbishes in an environmentally friendly manner and provides IT equipment to the UK and the developing world.">

		<meta name="keywords" content="CFC,CFC Recycling,Computers for Charity,computers for charities,computers for africa,containers of computers,containers to africa,third-world computing,old computers,redundant computers,computer disposal,obsolete computers,computer recycling,old IT, IT disposal,obsolete IT,IT recycling IT,old monitors,monitor disposal,monitor disposal,reconditioned computers,reconditioned IT equipment, second user PC, second user computers,weee directive,old university computers, environmentally friendly IT disposal, environmentally friendly computer disposal, used computer components,computers for community projects,computers for community groups,computers for community organisations,refurbishing computers,waste, reduction, reuse, re-use, recycle,environment, environmental, household waste, municipal waste">
 

<script language="javascript">

	function 1(){

		src="sidemenu.js";

	}

	function 2(){

		src="alttxt.js";

		}

	function LoadFunction(){

		function 1

		function 2

	}

</script>

		<style type="text/css">

		.navtext {

		width:235px;

		font-size:8pt;

		font-family:verdana;

		border-width:2px;

		border-style:outset;

		border-color:#006BAE;

		layer-background-color:#FFF6D9;

		background-color:#FFF6D9;

		color:black;

		}

		</style>
 

	 

</HEAD>

	<body onload="LoadFunctions()" background="images\WebFront.jpg">

		<table cellpadding="0" cellspacing="0" style="BORDER-COLLAPSE: collapse" bordercolor="#111111"

			width="100%" id="AutoNumber1">

			<tr>

				<td width="100%" colspan="3" align="center"><b> <font color="#0000ff" size="5">Welcome to 

							the Computers For Charity Home Page</font><font size="4"><br>

						</font><i>A voluntary, non-profitmaking Organisation

						<br>

							improving access to I.T. for Community Groups since 1993</i></b><hr>

				</td>

			</tr>

			<tr>

				<td width="33%" bgColor="#00ffff">

					<p align="center"><b><FONT size="4">Computers to Donate?<BR>

								&nbsp;&nbsp; </FONT></b><STRONG><FONT size="4">Call Us Between

								<BR>

							</FONT></STRONG><STRONG><FONT size="4">09:00 - 13:00 on 01288 36 11 99<BR>

								Monday - Friday</FONT></STRONG></p>

				</td>

				<td width="33%" align="center">

					<i><b>

							16 June 2008

							<br>

							<img src="images/marslogosmall.gif" alt="MARS Logo"><br>

							<A style="FONT-WEIGHT: bold; COLOR: #0000ff; TEXT-DECORATION: none" href="ContactUs.asp">

								Contact Us</A> </b></i>

				</td>

				<td width="34%" bgColor="#00ffff">

					<p align="center"><b><FONT size="4">Looking for a Computer?<BR>

							</FONT></b><STRONG><FONT size="4">Call Us Between

								<BR>

								13:30 - 17:00 on 01288 36 11 77<BR>

								Monday - Friday</FONT></STRONG></p>

				</td></TD>

			</tr>

			<tr>

				<td width="33%">

					<p align="center">We offer an easy way to refurbish your redundant computer 

						equipment in a reliable, efficient and safe way that will help protect our 

						environment and help community organisations.</p>

					<ul>

						<li>

							<a href="javascript:void(0)"  onmouseover="writetxt('<B>UK Collection Areas</B>'); return true" onmouseout="writetxt(0)">UK Collection Areas</a><br>

							<font size="2"><em>(Pentium III upwards)</em></font>

						<li>

							<b>Secure Data Removal Available</b>

						<li>

							<b>Third-Party Indemnity</b>

						<li>

							<b>WEEE Compliant Exemption 49</b>&nbsp;

						<li>

							<strong>

								<marquee>20,913 systems have gone to Africa so far....1,200 computers systems every month are required</marquee></strong></li>

					</ul>

					<p align="center"><i>Please use the links below to find out more</i></p>

				</td>

				<td width="33%">

					<p align="center">

						<IMG height="140" src="images\CFCLogo3D.gif" width="200" border="0">

						<BR>

						<a href="http://www.actnow.co.uk"><img src="actnow/logo.main.gif" alt="ActNow Logo" border="0">

						</a>

					</p>

				</td>

				<td width="34%">

					<p align="center">We can help with all your Information Technology requirements, 

						Whether you require just one system or hundreds on a distributed network, we 

						can help you to meet your expectations at the lowest cost.</p>

					<ul>

						<li>

							<b>All Systems Guaranteed</b>

						<li>

							<b>Delivery Throughout Mainland UK</b>

						<li>

							<strong>Pallets, 20ft or 40ft Containers to Africa</strong>

						<li>

							<strong>

								<marquee id="MARQUEE1">August, September &amp; November 2008 are available for booking</marquee></strong></li>

					</ul>

					<p align="center"><i>Please use the links below to find out more</i></p>

				</td>

			</tr>

		</table>

		<HR>Graham <A HREF=adminlogin.asp style='text-decoration:none font-family: Arial; color: #0000FF; font-Weight:bold'>Click Here</A><BR>16/06/2008 18:30:53<BR>Administrator<BR>

		<p><font size="2">Copyright © 2006 Computers For Charity</font></p>

		<p><font size="2">Computers for Charity is a non-profitmaking partnership offering UK 

				collection of redundant computer systems from businesses and individuals. 

				Established since 1993 we offer a complete </font><font size="2">Computer 

				Recycling and Computer Disposal&nbsp; service to all UK Mainland donors.</font></p>

<div id="navtxt" class="navtext" style="visibility:hidden; position:absolute; top:0px; left:-400px; z-index:10000; padding:10px"></div>
 

	</body>

</HTML>

Open in new window

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21795809
How large are alltext.js & sidemenu.js?

It is possible that the two script languages (i.e., JavaScript & VBScript) don't
play well together.  But, as Zvonko points out, it is much easier to understand
what is occurring when we can look at the actual code.
0
 

Author Comment

by:gjpitt
ID: 21795837
Sorry - did you mean the actual js script. I'm not sure if I should post it herer as it isn't mine although it is free to use - what do you think?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 41

Expert Comment

by:HonorGod
ID: 21796346
You could put pointers (complete URL) to it/them, that shouldn't be a problem
0
 

Author Comment

by:gjpitt
ID: 21796392
The code below makesthe sidemenu work perfectly and does point to the actual file inthe same folder as the main scripts. Repeating this line forthe alttxt.js file will make only one of  them work.
<script language="javascript" src="sidemenu.js"></script>

</HEAD>

	<body background="images\WebFront.jpg">

Open in new window

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21796503
unfortunately, we can't look at the code when you use a local file name.
We need to be able to look at the code to figure out what is causing the
interaction...
0
 

Author Comment

by:gjpitt
ID: 21796558
I wasn't able to attach the file as hey were js files and even zipped they were rejectd so I'll try pasting it here.


// SIDEMENU - V2.0

// BY: BRIAN GOSSELIN (HTTP://SCRIPTASYLUM.COM)

// ADD YOUR LINKS BELOW.
 

// TO ADD A HYPERLINK, THE FORMAT IS:                list[x]=new Array('text displayed' , 'url' , 'target' );

// TO ADD A NON-WORKING LINK, THE FORMAT IS:   list[x]=new Array('text displayed' , '' , '' );

// TO ADD A TITLEBAR, THE FORMAT IS:                   list[x]=new Array('text displayed' , null, null );
 

// KEEP NUMERICAL ORDER. START WITH 1. DO NOT SKIP A NUMBER.
 

var list=[[],

['<center><b>Clients</b></center>', null , null ],

['<b>Looking for a Desktop PC</b>' , 'communityservices.asp', '' ],

['<b>Looking for a Laptop</b>' , 'http://stores.ebay.co.uk/Computers-For-Charity' , '_blank' ],

['<b>Client Login</b>' , 'ClientLogin.asp' , '' ],

['<center><b>Donors</b></center>' ,  null , null ],

['<b>BusinessServices</b>' , 'donorwelcome.asp', ''],

['<b>Donor Terms & Conditions</b>' , 'tcd.pdf', '' ],

['<b>Donor Login</b>' , 'DonorLogin.asp' , '' ],

['<center><b>General</b></center>', null , null ],

['<b>Where do they go?</b>' , 'Gallery.asp' , '' ],

['<b>Community Links</b>' , 'communitylinks.asp' , '' ],

['<b>Contact Us</b>' , 'donorcontact.asp' , '' ],

['<b>About Us</b>' , 'About.asp', '' ],

['&nbsp;' , null , null ]

] 
 

// VARIOUS SETTINGS/COLORS/TEXT STYLES
 

var linktextcolor="black";                           // FONT COLOR OF THE LINKS

var linktexthovercolor="#00436e";                 // HOVER COLOR OF LINKS

var linktextsize=1;                                       // FONT SIZE OF THE LINKS (1 TO 6)

var linktextface="sans-serif";                   // FONT FACE OF THE LINKS

var linkbgcolor="lightgrey";                         // BACKGROUND COLOR OF THE LINK BARS

var linkhoverbgcolor="darkgray";              // BACKGROUND COLOR OF THE LINK BARS AS USER HOVERS OVER THEM

var cellheight=20;                                         // HEIGHT OF LINK BARS IN PIXELS (MIN=20).
 

var bartextcolor="white";                           // FONT COLOR OF THE "MENU" BAR AND ANY TITLEBARS

var bartextsize=1;                                       // FONT SIZE OF THE MENU/TITLE BARS

var bartextface="sans-serif";                   // FONT FACE OF THE MENU/TITLE BARS

var barbgcolor="#00436e";                                // BACKGROUND COLOR OF THE MENU/TITLE BARS
 

var bordercolor="black";                           // BORDER COLOR SURROUNDING ALL BARS
 

var barwidth=22;                                        // WIDTH OF THE "MENU" BAR (SET WIDE ENOUGH SO LINKTEXT DOESN'T WRAP)

var follow=true;                                          // true=MENU FOLLOWS PAGE SCROLL, false=MENU IS STATIONARY

var menuwidth=160;                                    // WIDTH OF TEXT LINK BARS

var yoffset=140;                                           // OFFSET FROM TOP OF THE PAGE
 
 

//*********DO NOT EDIT BEYOND THIS POINT**********//

var smenu, pagedone=false, id, loff=1;

linktextsize=Math.max(Math.min(linktextsize,6),1);

if(linktextsize>6)linktextsize=6; if(linktextsize<1)linktextsize=1;

if((linktextsize*5+10)>cellheight)cellheight=Math.max(20,(linktextsize*5+10));

var btbl='<table cellpadding="0" cellspacing="0" border="0"  width="'+menuwidth+'"><tr><td valign="center" width="'+menuwidth+'" height="'+cellheight+'" ';

var NS4=(navigator.appName.indexOf("Netscape")>=0 && parseFloat(navigator.appVersion) >= 4 && parseFloat(navigator.appVersion) < 5)? true : false;

var IE4=(document.all)? true : false;

var NS6=(parseFloat(navigator.appVersion) >= 5 && navigator.appName.indexOf("Netscape")>=0 )? true: false;

var txt=(NS4)?'<layer name="smenu" bgcolor="'+bordercolor+'" top="0" left="0" onmouseover="showmenu(true)" width="'+(menuwidth+barwidth+3)+'" visibility="hide" onmouseout="showmenu(false)">' : '<div id="smenu" style="width:'+(menuwidth+barwidth+3)+'; position:absolute; left:0px; top:0px; background-color:'+bordercolor+'; visibility:hidden" onmouseover="showmenu(true)" onmouseout="showmenu(false)">';

txt+='<table cellpadding="0" cellspacing="1" border="0" bgcolor="'+bordercolor+'" width="'+(menuwidth+barwidth+3)+'">';

for(i=1;i<list.length;i++){

if(list[i][1]!=null){

txt+='<tr><td width="'+menuwidth+'" height="'+cellheight+'">';

txt+=(NS4)?'<ilayer>' : '<div style="position:relative; width:'+menuwidth+'px; height:'+cellheight+'px;">';

txt+=(NS4)?'<layer name="h'+(i-loff)+'" height="'+cellheight+'" visibility="hide" bgcolor="'+linkhoverbgcolor+'">'+btbl+' bgcolor="'+linkhoverbgcolor+'"><font color="'+linktexthovercolor+'" size="'+linktextsize+'" face="'+linktextface+'">&nbsp;'+list[i][0]+'</font></td></tr></table></layer>' : '<div id="h'+i+'" style="position:absolute; top:0px; left:0px; width:'+menuwidth+'px; height:'+cellheight+'px; background-color:'+linkhoverbgcolor+';">'+btbl+' bgcolor="'+linkhoverbgcolor+'"><font color="'+linktexthovercolor+'" size="'+linktextsize+'" face="'+linktextface+'">&nbsp;'+list[i][0]+'</font></td></tr></table></div>';

txt+=(NS4)?'<layer name="n'+(i-loff)+'" height="'+cellheight+'" bgcolor="'+linkbgcolor+'">'+btbl+' bgcolor="'+linkbgcolor+'"><font color="'+linktextcolor+'" size="'+linktextsize+'" face="'+linktextface+'">&nbsp;'+list[i][0]+'</font></td></tr></table></layer>' : '<div id="n'+i+'" style="position:absolute; top:0px; left:0px; width:'+menuwidth+'px; height:'+cellheight+'px; background-color:'+linkbgcolor+';">'+btbl+' bgcolor="'+linkbgcolor+'"><font color="'+linktextcolor+'" size="'+linktextsize+'" face="'+linktextface+'">&nbsp;'+list[i][0]+'</font></td></tr></table></div>';

txt+=(NS4)?'<layer height="'+cellheight+'" onmouseover="hoverlayer(\'h\',\'n\','+(i-loff)+')" onmouseout="hoverlayer(\'n\',\'h\','+(i-loff)+')">' : '<div style="position:absolute; top:0px; left:0px; width:'+menuwidth+'px; height:'+cellheight+'px;" onmouseover="hoverlayer(\'h\',\'n\','+i+')" onmouseout="hoverlayer(\'n\',\'h\','+i+')">'+btbl+'>';

txt+='<a href="'+list[i][1]+'" target="'+list[i][2]+'"><img src="blank.gif" width="'+menuwidth+'" height="'+cellheight+'" border="0"></a>';

txt+=(NS4)?'</layer></ilayer></td>' : '</td></tr></table></div></div></td>';

}else{

txt+='<tr height="'+cellheight+'"><td width="'+menuwidth+'" bgcolor="'+barbgcolor+'" height="'+cellheight+'" valign="center"><font color="'+bartextcolor+'" size="'+linktextsize+'" face="'+linktextface+'">'+list[i][0]+'</font></td>';

loff+=1;

}

if(i==1)txt+='<td rowspan="'+(list.length-1)+'" bgcolor="'+barbgcolor+'" width="'+barwidth+'" height="'+cellheight+'" align="center"><font color="'+bartextcolor+'" size="'+bartextsize+'" face="'+bartextface+'"><b>M<br>E<br>N<br>U</b></font></td>';

txt+='</tr>';

}

txt+='</table>';

txt+=(NS4)?'</layer>' : '</div>';

document.write(txt);
 

function hoverlayer(h,n,num){

if(NS6){

document.getElementById(h+num).style.visibility="visible";

document.getElementById(n+num).style.visibility="hidden";

}

if(IE4){

document.all[h+num].style.visibility="visible";

document.all[n+num].style.visibility="hidden";

}

if(NS4){

smenu.document.layers[num].document.layers[h+num].visibility="show";

smenu.document.layers[num].document.layers[n+num].visibility="hide";

}}

function init(){

if(NS4){

smenu=document.smenu;

movexto(-menuwidth-2);

smenu.visibility="show";

}

else if(IE4){

smenu=document.all.smenu;

movexto(-menuwidth-2);

smenu.style.visibility="visible";

}

else if(NS6){

smenu=document.getElementById('smenu');

movexto(-menuwidth-2);

smenu.style.visibility="visible";

}

pagedone=true;

setInterval('movemenu()', 75);

}

function movemenu(){

if(follow){

var y=(NS4)?smenu.top:parseInt(smenu.style.top);

var sy=(IE4||IE5)?document.body.scrollTop:window.pageYOffset;

moveyto(((sy-y+yoffset)/3+3)+y);

}}

function showmenu(toshow){

if(pagedone){

if(toshow){

clearTimeout(id);

movexto(0);

}else id=setTimeout('movexto(-menuwidth-2)',200);

}}

function movexto(x){

if(NS4)smenu.left=x;

if(IE4||NS6)smenu.style.left=x+'px';

}

function moveyto(y){

if(NS4)smenu.top=y;

if(IE4||NS6)smenu.style.top=y+'px';

}

if(NS4)window.onresize=new Function("history.go(0)");

window.onload=init;
 

AND
 

/*********************************************************************************************
 

ALTTXT V1.6

BY: BRIAN GOSSELIN OF SCRIPTASYLUM.COM
 

INSTRUCTIONS:
 

1: PUT THESE DIVS IN THE END OF THE BODY AREA:
 

   <div id="navtxt" class="navtext" style="visibility:hidden; position:absolute; top:0px; left:-400px; z-index:10000; padding:10px"></div>
 

2: NEXT, PLACE THIS STYLE DECLARATION IN THE HEAD SECTION OF YOUR PAGE (JUST CHANGE YOUR SETTINGS):
 

   .navtext {

   width:235px;

   font-size:8pt;

   font-family:verdana;

   border-width:2px;

   border-style:outset;

   border-color:#006BAE;

   layer-background-color:#FFF6D9;

   background-color:#FFF6D9;

   color:black;

   }
 

3: THEN, SET THE 6 SETTINGS BELOW ( dofade, centertext, xoffset, yoffset, mousefollow, and hideDelay ) AS DESIRED.
 

4: LASTLY ADD THE MOUSEOVER/MOUSEOUT EVENT HANDLERS TO EACH LINK THAT YOU WANT THIS EFFECT FOR:
 

     EXAMPLE: <a href="scriptasylum.com" onmouseover="writetxt('Popup text')" onmouseout="writetxt(0)">Link text</a>
 

NOTES:
 

  > YOU CAN CAUSE A BOX *NOT* TO DISAPPEAR ONCE THE MOUSE LEAVES THE LINK BY SIMPLY OMITTING THE

    onmouseout="writetxt(0)" PART. THIS WILL CAUSE THE CURRENT BOX TO REMAIN VISIBLE. THIS IS BEST

    USED WHEN mousefollow MODE IS DISABLED (SET TO false).
 

  > YOU CAN SET THE PADDING STYLE ATTRIBUTE *ONLY* IN THE navtxt DIV ITSELF AND *NOT* IN THE STYLE

    SHEET AT THE TOP OF THE PAGE. OTHERWISE NS4 DISPLAYS SOME WEIRD BEHAVIOR. ALSO, THE PADDING ATTRIBUTE

    ONLY HAS AN EFFECT IN IE4+ AND NS6+.
 

*********************************************************************************************/
 

var dofade=true;       // ENABLES FADE-IN EFFECT (FOR IE4+ AND NS6 ONLY)
 

var centertext=false;  // CENTERS THE TEXT INSIDE THE BOX. YOU CAN'T SIMPLY DO THIS VIA "STYLE" BECAUSE OF NS4.

                       // OTHERWISE, TEXT IS LEFT-JUSTIFIED.
 

var xoffset=9;         // HORIZONTAL PIXEL COUNT FROM CURSOR
 

var yoffset=25;        // VERTICAL PIXEL COUNT FROM CURSOR
 

var mousefollow=false; // ENABLES MOUSE FOLLOW MODE WHERE THE BOX CONTINUES TO FOLLOW THE MOUSE. SET TO false TO

                       // LOCK THE BOX WHEREVER IT INITIALLY APPEARS.
 

var hideDelay=300;     // DELAY IN MILLISECONDS ( 1 SECOND = 1000 MILLISECONDS) FROM WHEN YOU HOVER OUT OF LINK

                       // AND THE BOX DISAPPEARS ONLY WHEN "mousefollow" IS SET TO "false".

                       // THIS WILL GIVE THE USER TIME TO CLICK A LINK OR WHATEVER IN THE BOX BEFORE IT DISAPPEARS.
 

////////////////////////////// NO NEED TO EDIT BEYOND THIS POINT //////////////////////////////////////
 

function altProps(){

this.w3c=(document.getElementById)?true:false;

this.ns4=(document.layers)?true:false;

this.ie4=(document.all && !this.w3c)?true:false;

this.ie5=(document.all && this.w3c)?true:false;

this.ns6=(this.w3c && navigator.appName.indexOf("Netscape")>=0 )?true:false;

this.w_y=0;

this.w_x=0;

this.navtxt=null;

this.boxheight=0;

this.boxwidth=0;

this.ishover=false;

this.ieop=0;

this.op_id=0;

this.oktomove=false;

this.dy=0;

}
 

var AT=new altProps();
 

function toggle_centertext(){

centertext=!centertext;

}
 

function toggle_mousefollow(){

mousefollow=!mousefollow;

}
 

function toggle_dofade(){

dofade=!dofade;

if(!dofade)AT.ieop=100;

}
 
 

function getwindowdims(){

AT.w_y=(AT.ie5||AT.ie4)?document.body.clientHeight:window.innerHeight;

AT.w_x=(AT.ie5||AT.ie4)?document.body.clientWidth:window.innerWidth;

}
 

function getboxwidth(){

if(AT.ns4)AT.boxwidth=(AT.navtxt.document.width)? AT.navtxt.document.width : AT.navtxt.clip.width;

else if(AT.ie4)AT.boxwidth=(AT.navtxt.style.pixelWidth)? AT.navtxt.style.pixelWidth : AT.navtxt.offsetWidth;

else AT.boxwidth=(AT.navtxt.style.width)? parseInt(AT.navtxt.style.width) : parseInt(AT.navtxt.offsetWidth);

}
 

function getboxheight(){

if(AT.ns4)AT.boxheight=(AT.navtxt.document.height)? AT.navtxt.document.height : AT.navtxt.clip.height;

else if(AT.ie4)AT.boxheight=(AT.navtxt.style.pixelHeight)? AT.navtxt.style.pixelHeight : AT.navtxt.offsetHeight;

else AT.boxheight=parseInt(AT.navtxt.offsetHeight);

}
 

function movenavtxt(x,y){

if(AT.ns4)AT.navtxt.moveTo(x,y);

else{

AT.navtxt.style.left=x+'px';

AT.navtxt.style.top=y+'px';

}}
 

function getpagescrolly(){

if(AT.ie5||AT.ie4)return document.body.scrollTop;

else return window.pageYOffset;

}
 

function getpagescrollx(){

if(AT.ie5||AT.ie4)return document.body.scrollLeft;

else return window.pageXOffset;

}
 

function writeindiv(text){

if(AT.ns4){

AT.navtxt.document.open();

AT.navtxt.document.write(text);

AT.navtxt.document.close();

}

else AT.navtxt.innerHTML=text;

}
 

function writetxt(text){

if(dofade && (AT.ie4||AT.w3c))clearInterval(AT.op_id);

if(text!=0){

if(!mousefollow)clearTimeout(AT.dy);

AT.oktomove=true;

AT.ishover=true;

if(AT.ns4)text='<div class="navtext">'+((centertext)?'<center>':'')+text+((centertext)?'</center>':'')+'</div>';

if(AT.w3c||AT.ie4)AT.navtxt.style.textAlign=(centertext)?"center":"left";

writeindiv(text);

if(AT.ns4)AT.navtxt.visibility="show";

else{

AT.navtxt.style.visibility="visible";

AT.navtxt.style.display="block";

}

getboxheight();

if((AT.w3c||AT.ie4) && dofade){

if(AT.ie4||AT.ie5)AT.navtxt.style.filter="alpha(opacity=0)";

if(AT.ns6)AT.navtxt.style.MozOpacity=0;

AT.ieop=0;

AT.op_id=setInterval('incropacity()',50);

}}else{

if(mousefollow)hideAlttxt();

else AT.dy=setTimeout('hideAlttxt()',hideDelay);

}}
 

function hideAlttxt(){

if(AT.ns4)AT.navtxt.visibility="hide";

else{

AT.navtxt.style.display="none";

AT.navtxt.style.visibility="hidden";

}

movenavtxt(-AT.boxwidth-10,0);

writeindiv('');

}
 

function incropacity(){

if(AT.ieop<=100){

AT.ieop+=7;

if(AT.ie4||AT.ie5)AT.navtxt.style.filter="alpha(opacity="+AT.ieop+")";

if(AT.ns6)AT.navtxt.style.MozOpacity=AT.ieop/100;

}else clearInterval(AT.op_id);

}
 

function moveobj(evt){

mx=(AT.ie5||AT.ie4)?event.clientX:evt.pageX;

my=(AT.ie5||AT.ie4)?event.clientY:evt.pageY;

if(AT.ishover && AT.oktomove){

margin=(AT.ie4||AT.ie5)?5:25;

if(AT.ns6)if(document.height+27-window.innerHeight<0)margin=15;

if(AT.ns4)if(document.height-window.innerHeight<0)margin=10;

if(AT.ns4||AT.ns6)mx-=getpagescrollx();

if(AT.ns4)my-=getpagescrolly();

xoff=mx+xoffset;

yoff=(my+AT.boxheight+yoffset-((AT.ns6)?getpagescrolly():0)>=AT.w_y)? -5-AT.boxheight-yoffset: yoffset;

movenavtxt( Math.min(AT.w_x-AT.boxwidth-margin , Math.max(2,xoff))+getpagescrollx(), my+yoff+((!AT.ns6)?getpagescrolly():0));

if(!mousefollow)AT.oktomove=false;

}}
 
 

window.onload=function(){

  AT.navtxt=(AT.ns4)?document.layers['navtxt']:(AT.ie4)?document.all['navtxt']:(AT.w3c)?document.getElementById('navtxt'):null;

  getboxwidth();

  getboxheight();

  getwindowdims();

  if(AT.ie4||AT.ie5&&dofade)AT.navtxt.style.filter="alpha(opacity=100)";

  AT.navtxt.onmouseover=function(){

  if(!mousefollow)clearTimeout(AT.dy);

  }

  AT.navtxt.onmouseout=function(){

  if(!mousefollow)AT.dy=setTimeout('hideAlttxt()',hideDelay);

  }

  if(AT.ns4)document.captureEvents(Event.MOUSEMOVE);

  document.onmousemove=moveobj;

  window.onresize=getwindowdims;

}

Open in new window

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21796726
I bet they don't work together because each has the


window.onload=function() {
...
}


at the end...
0
 

Author Comment

by:gjpitt
ID: 21796748
How do I put them together in one function that I can call OnLoad in the Body element?

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21797259
well, the easiest is to create a named function in each file.

For example, instead of:

window.onload=function() {
...
}

make it:

function sidemenuInit() {
...
}

and in the other file:

function alltxtInit() {
...
}

Then, you need only have one:

window.onload = function() {
  sidemenuInit();
  alltxtInit();
}

That's the "quick and dirty" way to do it.
The "better" way is to have a chained event handler
for your onload routines using something like the
addLoadEvent routine described here:

http://www.webreference.com/programming/javascript/onloads/
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 21797953
Hello Graham, I have to beg your pardon. I assumed you are to lazy to copy your script to the question and that you therefore pasted sum scratchy dummy pseudo code. Now I see that is your REAL code! You are not lazy you are simply a beginner and that is absolutely no shame, everyone is always at some point for some topic beginner.
I mean this code:
<script language="javascript">
      function 1(){
            src="sidemenu.js";
      }
      function 2(){
            src="alttxt.js";
            }
      function LoadFunction(){
            function 1
            function 2
      }
</script>
That code is NOT valid.
You cannot name functions by numbers only, you cannot call them wuthout braces and it does not help to assign some src var to load a script file, you see?

0
 

Author Comment

by:gjpitt
ID: 21803079
OK I think I created a named function in each file alonog the lines suggested.
Put both files together into one file and called it startMenu.js

Then tried calling it in the head section like so.
<script language="javascript" src="startMenu.js"></script>

Obviously I'm doing something wrong but not a clue what.
function sidemenuinit() {

// SIDEMENU - V2.0

// BY: BRIAN GOSSELIN (HTTP://SCRIPTASYLUM.COM)

// ADD YOUR LINKS BELOW.
 

// TO ADD A HYPERLINK, THE FORMAT IS:                list[x]=new Array('text displayed' , 'url' , 'target' );

// TO ADD A NON-WORKING LINK, THE FORMAT IS:   list[x]=new Array('text displayed' , '' , '' );

// TO ADD A TITLEBAR, THE FORMAT IS:                   list[x]=new Array('text displayed' , null, null );
 

// KEEP NUMERICAL ORDER. START WITH 1. DO NOT SKIP A NUMBER.
 

var list=[[],

['<center><b>Clients</b></center>', null , null ],

['<b>Looking for a Desktop PC</b>' , 'communityservices.asp', '' ],

['<b>Looking for a Laptop</b>' , 'http://stores.ebay.co.uk/Computers-For-Charity' , '_blank' ],

['<b>Client Login</b>' , 'ClientLogin.asp' , '' ],

['<center><b>Donors</b></center>' ,  null , null ],

['<b>BusinessServices</b>' , 'donorwelcome.asp', ''],

['<b>Donor Terms & Conditions</b>' , 'tcd.pdf', '' ],

['<b>Donor Login</b>' , 'DonorLogin.asp' , '' ],

['<center><b>General</b></center>', null , null ],

['<b>Where do they go?</b>' , 'Gallery.asp' , '' ],

['<b>Community Links</b>' , 'communitylinks.asp' , '' ],

['<b>Contact Us</b>' , 'donorcontact.asp' , '' ],

['<b>About Us</b>' , 'About.asp', '' ],

['&nbsp;' , null , null ]

] 
 

// VARIOUS SETTINGS/COLORS/TEXT STYLES
 

var linktextcolor="black";                           // FONT COLOR OF THE LINKS

var linktexthovercolor="#00436e";                 // HOVER COLOR OF LINKS

var linktextsize=1;                                       // FONT SIZE OF THE LINKS (1 TO 6)

var linktextface="sans-serif";                   // FONT FACE OF THE LINKS

var linkbgcolor="lightgrey";                         // BACKGROUND COLOR OF THE LINK BARS

var linkhoverbgcolor="darkgray";              // BACKGROUND COLOR OF THE LINK BARS AS USER HOVERS OVER THEM

var cellheight=20;                                         // HEIGHT OF LINK BARS IN PIXELS (MIN=20).
 

var bartextcolor="white";                           // FONT COLOR OF THE "MENU" BAR AND ANY TITLEBARS

var bartextsize=1;                                       // FONT SIZE OF THE MENU/TITLE BARS

var bartextface="sans-serif";                   // FONT FACE OF THE MENU/TITLE BARS

var barbgcolor="#00436e";                                // BACKGROUND COLOR OF THE MENU/TITLE BARS
 

var bordercolor="black";                           // BORDER COLOR SURROUNDING ALL BARS
 

var barwidth=22;                                        // WIDTH OF THE "MENU" BAR (SET WIDE ENOUGH SO LINKTEXT DOESN'T WRAP)

var follow=true;                                          // true=MENU FOLLOWS PAGE SCROLL, false=MENU IS STATIONARY

var menuwidth=160;                                    // WIDTH OF TEXT LINK BARS

var yoffset=10;                                           // OFFSET FROM TOP OF THE PAGE
 
 

//*********DO NOT EDIT BEYOND THIS POINT**********//

var smenu, pagedone=false, id, loff=1;

linktextsize=Math.max(Math.min(linktextsize,6),1);

if(linktextsize>6)linktextsize=6; if(linktextsize<1)linktextsize=1;

if((linktextsize*5+10)>cellheight)cellheight=Math.max(20,(linktextsize*5+10));

var btbl='<table cellpadding="0" cellspacing="0" border="0"  width="'+menuwidth+'"><tr><td valign="center" width="'+menuwidth+'" height="'+cellheight+'" ';

var NS4=(navigator.appName.indexOf("Netscape")>=0 && parseFloat(navigator.appVersion) >= 4 && parseFloat(navigator.appVersion) < 5)? true : false;

var IE4=(document.all)? true : false;

var NS6=(parseFloat(navigator.appVersion) >= 5 && navigator.appName.indexOf("Netscape")>=0 )? true: false;

var txt=(NS4)?'<layer name="smenu" bgcolor="'+bordercolor+'" top="0" left="0" onmouseover="showmenu(true)" width="'+(menuwidth+barwidth+3)+'" visibility="hide" onmouseout="showmenu(false)">' : '<div id="smenu" style="width:'+(menuwidth+barwidth+3)+'; position:absolute; left:0px; top:0px; background-color:'+bordercolor+'; visibility:hidden" onmouseover="showmenu(true)" onmouseout="showmenu(false)">';

txt+='<table cellpadding="0" cellspacing="1" border="0" bgcolor="'+bordercolor+'" width="'+(menuwidth+barwidth+3)+'">';

for(i=1;i<list.length;i++){

if(list[i][1]!=null){

txt+='<tr><td width="'+menuwidth+'" height="'+cellheight+'">';

txt+=(NS4)?'<ilayer>' : '<div style="position:relative; width:'+menuwidth+'px; height:'+cellheight+'px;">';

txt+=(NS4)?'<layer name="h'+(i-loff)+'" height="'+cellheight+'" visibility="hide" bgcolor="'+linkhoverbgcolor+'">'+btbl+' bgcolor="'+linkhoverbgcolor+'"><font color="'+linktexthovercolor+'" size="'+linktextsize+'" face="'+linktextface+'">&nbsp;'+list[i][0]+'</font></td></tr></table></layer>' : '<div id="h'+i+'" style="position:absolute; top:0px; left:0px; width:'+menuwidth+'px; height:'+cellheight+'px; background-color:'+linkhoverbgcolor+';">'+btbl+' bgcolor="'+linkhoverbgcolor+'"><font color="'+linktexthovercolor+'" size="'+linktextsize+'" face="'+linktextface+'">&nbsp;'+list[i][0]+'</font></td></tr></table></div>';

txt+=(NS4)?'<layer name="n'+(i-loff)+'" height="'+cellheight+'" bgcolor="'+linkbgcolor+'">'+btbl+' bgcolor="'+linkbgcolor+'"><font color="'+linktextcolor+'" size="'+linktextsize+'" face="'+linktextface+'">&nbsp;'+list[i][0]+'</font></td></tr></table></layer>' : '<div id="n'+i+'" style="position:absolute; top:0px; left:0px; width:'+menuwidth+'px; height:'+cellheight+'px; background-color:'+linkbgcolor+';">'+btbl+' bgcolor="'+linkbgcolor+'"><font color="'+linktextcolor+'" size="'+linktextsize+'" face="'+linktextface+'">&nbsp;'+list[i][0]+'</font></td></tr></table></div>';

txt+=(NS4)?'<layer height="'+cellheight+'" onmouseover="hoverlayer(\'h\',\'n\','+(i-loff)+')" onmouseout="hoverlayer(\'n\',\'h\','+(i-loff)+')">' : '<div style="position:absolute; top:0px; left:0px; width:'+menuwidth+'px; height:'+cellheight+'px;" onmouseover="hoverlayer(\'h\',\'n\','+i+')" onmouseout="hoverlayer(\'n\',\'h\','+i+')">'+btbl+'>';

txt+='<a href="'+list[i][1]+'" target="'+list[i][2]+'"><img src="blank.gif" width="'+menuwidth+'" height="'+cellheight+'" border="0"></a>';

txt+=(NS4)?'</layer></ilayer></td>' : '</td></tr></table></div></div></td>';

}else{

txt+='<tr height="'+cellheight+'"><td width="'+menuwidth+'" bgcolor="'+barbgcolor+'" height="'+cellheight+'" valign="center"><font color="'+bartextcolor+'" size="'+linktextsize+'" face="'+linktextface+'">'+list[i][0]+'</font></td>';

loff+=1;

}

if(i==1)txt+='<td rowspan="'+(list.length-1)+'" bgcolor="'+barbgcolor+'" width="'+barwidth+'" height="'+cellheight+'" align="center"><font color="'+bartextcolor+'" size="'+bartextsize+'" face="'+bartextface+'"><b>M<br>E<br>N<br>U</b></font></td>';

txt+='</tr>';

}

txt+='</table>';

txt+=(NS4)?'</layer>' : '</div>';

document.write(txt);
 

function hoverlayer(h,n,num){

if(NS6){

document.getElementById(h+num).style.visibility="visible";

document.getElementById(n+num).style.visibility="hidden";

}

if(IE4){

document.all[h+num].style.visibility="visible";

document.all[n+num].style.visibility="hidden";

}

if(NS4){

smenu.document.layers[num].document.layers[h+num].visibility="show";

smenu.document.layers[num].document.layers[n+num].visibility="hide";

}}

function init(){

if(NS4){

smenu=document.smenu;

movexto(-menuwidth-2);

smenu.visibility="show";

}

else if(IE4){

smenu=document.all.smenu;

movexto(-menuwidth-2);

smenu.style.visibility="visible";

}

else if(NS6){

smenu=document.getElementById('smenu');

movexto(-menuwidth-2);

smenu.style.visibility="visible";

}

pagedone=true;

setInterval('movemenu()', 75);

}

function movemenu(){

if(follow){

var y=(NS4)?smenu.top:parseInt(smenu.style.top);

var sy=(IE4||IE5)?document.body.scrollTop:window.pageYOffset;

moveyto(((sy-y+yoffset)/3+3)+y);

}}

function showmenu(toshow){

if(pagedone){

if(toshow){

clearTimeout(id);

movexto(0);

}else id=setTimeout('movexto(-menuwidth-2)',200);

}}

function movexto(x){

if(NS4)smenu.left=x;

if(IE4||NS6)smenu.style.left=x+'px';

}

function moveyto(y){

if(NS4)smenu.top=y;

if(IE4||NS6)smenu.style.top=y+'px';

}

if(NS4)window.onresize=new Function("history.go(0)");

}
 

function alttxtinit() {

/*********************************************************************************************
 

ALTTXT V1.6

BY: BRIAN GOSSELIN OF SCRIPTASYLUM.COM
 

INSTRUCTIONS:
 

1: PUT THESE DIVS IN THE END OF THE BODY AREA:
 

   <div id="navtxt" class="navtext" style="visibility:hidden; position:absolute; top:0px; left:-400px; z-index:10000; padding:10px"></div>
 

2: NEXT, PLACE THIS STYLE DECLARATION IN THE HEAD SECTION OF YOUR PAGE (JUST CHANGE YOUR SETTINGS):
 

   .navtext {

   width:235px;

   font-size:8pt;

   font-family:verdana;

   border-width:2px;

   border-style:outset;

   border-color:#006BAE;

   layer-background-color:#FFF6D9;

   background-color:#FFF6D9;

   color:black;

   }
 

3: THEN, SET THE 6 SETTINGS BELOW ( dofade, centertext, xoffset, yoffset, mousefollow, and hideDelay ) AS DESIRED.
 

4: LASTLY ADD THE MOUSEOVER/MOUSEOUT EVENT HANDLERS TO EACH LINK THAT YOU WANT THIS EFFECT FOR:
 

     EXAMPLE: <a href="scriptasylum.com" onmouseover="writetxt('Popup text')" onmouseout="writetxt(0)">Link text</a>
 

NOTES:
 

  > YOU CAN CAUSE A BOX *NOT* TO DISAPPEAR ONCE THE MOUSE LEAVES THE LINK BY SIMPLY OMITTING THE

    onmouseout="writetxt(0)" PART. THIS WILL CAUSE THE CURRENT BOX TO REMAIN VISIBLE. THIS IS BEST

    USED WHEN mousefollow MODE IS DISABLED (SET TO false).
 

  > YOU CAN SET THE PADDING STYLE ATTRIBUTE *ONLY* IN THE navtxt DIV ITSELF AND *NOT* IN THE STYLE

    SHEET AT THE TOP OF THE PAGE. OTHERWISE NS4 DISPLAYS SOME WEIRD BEHAVIOR. ALSO, THE PADDING ATTRIBUTE

    ONLY HAS AN EFFECT IN IE4+ AND NS6+.
 

*********************************************************************************************/
 

var dofade=true;       // ENABLES FADE-IN EFFECT (FOR IE4+ AND NS6 ONLY)
 

var centertext=false;  // CENTERS THE TEXT INSIDE THE BOX. YOU CAN'T SIMPLY DO THIS VIA "STYLE" BECAUSE OF NS4.

                       // OTHERWISE, TEXT IS LEFT-JUSTIFIED.
 

var xoffset=9;         // HORIZONTAL PIXEL COUNT FROM CURSOR
 

var yoffset=25;        // VERTICAL PIXEL COUNT FROM CURSOR
 

var mousefollow=false; // ENABLES MOUSE FOLLOW MODE WHERE THE BOX CONTINUES TO FOLLOW THE MOUSE. SET TO false TO

                       // LOCK THE BOX WHEREVER IT INITIALLY APPEARS.
 

var hideDelay=300;     // DELAY IN MILLISECONDS ( 1 SECOND = 1000 MILLISECONDS) FROM WHEN YOU HOVER OUT OF LINK

                       // AND THE BOX DISAPPEARS ONLY WHEN "mousefollow" IS SET TO "false".

                       // THIS WILL GIVE THE USER TIME TO CLICK A LINK OR WHATEVER IN THE BOX BEFORE IT DISAPPEARS.
 

////////////////////////////// NO NEED TO EDIT BEYOND THIS POINT //////////////////////////////////////
 

function altProps(){

this.w3c=(document.getElementById)?true:false;

this.ns4=(document.layers)?true:false;

this.ie4=(document.all && !this.w3c)?true:false;

this.ie5=(document.all && this.w3c)?true:false;

this.ns6=(this.w3c && navigator.appName.indexOf("Netscape")>=0 )?true:false;

this.w_y=0;

this.w_x=0;

this.navtxt=null;

this.boxheight=0;

this.boxwidth=0;

this.ishover=false;

this.ieop=0;

this.op_id=0;

this.oktomove=false;

this.dy=0;

}
 

var AT=new altProps();
 

function toggle_centertext(){

centertext=!centertext;

}
 

function toggle_mousefollow(){

mousefollow=!mousefollow;

}
 

function toggle_dofade(){

dofade=!dofade;

if(!dofade)AT.ieop=100;

}
 
 

function getwindowdims(){

AT.w_y=(AT.ie5||AT.ie4)?document.body.clientHeight:window.innerHeight;

AT.w_x=(AT.ie5||AT.ie4)?document.body.clientWidth:window.innerWidth;

}
 

function getboxwidth(){

if(AT.ns4)AT.boxwidth=(AT.navtxt.document.width)? AT.navtxt.document.width : AT.navtxt.clip.width;

else if(AT.ie4)AT.boxwidth=(AT.navtxt.style.pixelWidth)? AT.navtxt.style.pixelWidth : AT.navtxt.offsetWidth;

else AT.boxwidth=(AT.navtxt.style.width)? parseInt(AT.navtxt.style.width) : parseInt(AT.navtxt.offsetWidth);

}
 

function getboxheight(){

if(AT.ns4)AT.boxheight=(AT.navtxt.document.height)? AT.navtxt.document.height : AT.navtxt.clip.height;

else if(AT.ie4)AT.boxheight=(AT.navtxt.style.pixelHeight)? AT.navtxt.style.pixelHeight : AT.navtxt.offsetHeight;

else AT.boxheight=parseInt(AT.navtxt.offsetHeight);

}
 

function movenavtxt(x,y){

if(AT.ns4)AT.navtxt.moveTo(x,y);

else{

AT.navtxt.style.left=x+'px';

AT.navtxt.style.top=y+'px';

}}
 

function getpagescrolly(){

if(AT.ie5||AT.ie4)return document.body.scrollTop;

else return window.pageYOffset;

}
 

function getpagescrollx(){

if(AT.ie5||AT.ie4)return document.body.scrollLeft;

else return window.pageXOffset;

}
 

function writeindiv(text){

if(AT.ns4){

AT.navtxt.document.open();

AT.navtxt.document.write(text);

AT.navtxt.document.close();

}

else AT.navtxt.innerHTML=text;

}
 

function writetxt(text){

if(dofade && (AT.ie4||AT.w3c))clearInterval(AT.op_id);

if(text!=0){

if(!mousefollow)clearTimeout(AT.dy);

AT.oktomove=true;

AT.ishover=true;

if(AT.ns4)text='<div class="navtext">'+((centertext)?'<center>':'')+text+((centertext)?'</center>':'')+'</div>';

if(AT.w3c||AT.ie4)AT.navtxt.style.textAlign=(centertext)?"center":"left";

writeindiv(text);

if(AT.ns4)AT.navtxt.visibility="show";

else{

AT.navtxt.style.visibility="visible";

AT.navtxt.style.display="block";

}

getboxheight();

if((AT.w3c||AT.ie4) && dofade){

if(AT.ie4||AT.ie5)AT.navtxt.style.filter="alpha(opacity=0)";

if(AT.ns6)AT.navtxt.style.MozOpacity=0;

AT.ieop=0;

AT.op_id=setInterval('incropacity()',50);

}}else{

if(mousefollow)hideAlttxt();

else AT.dy=setTimeout('hideAlttxt()',hideDelay);

}}
 

function hideAlttxt(){

if(AT.ns4)AT.navtxt.visibility="hide";

else{

AT.navtxt.style.display="none";

AT.navtxt.style.visibility="hidden";

}

movenavtxt(-AT.boxwidth-10,0);

writeindiv('');

}
 

function incropacity(){

if(AT.ieop<=100){

AT.ieop+=7;

if(AT.ie4||AT.ie5)AT.navtxt.style.filter="alpha(opacity="+AT.ieop+")";

if(AT.ns6)AT.navtxt.style.MozOpacity=AT.ieop/100;

}else clearInterval(AT.op_id);

}
 

function moveobj(evt){

mx=(AT.ie5||AT.ie4)?event.clientX:evt.pageX;

my=(AT.ie5||AT.ie4)?event.clientY:evt.pageY;

if(AT.ishover && AT.oktomove){

margin=(AT.ie4||AT.ie5)?5:25;

if(AT.ns6)if(document.height+27-window.innerHeight<0)margin=15;

if(AT.ns4)if(document.height-window.innerHeight<0)margin=10;

if(AT.ns4||AT.ns6)mx-=getpagescrollx();

if(AT.ns4)my-=getpagescrolly();

xoff=mx+xoffset;

yoff=(my+AT.boxheight+yoffset-((AT.ns6)?getpagescrolly():0)>=AT.w_y)? -5-AT.boxheight-yoffset: yoffset;

movenavtxt( Math.min(AT.w_x-AT.boxwidth-margin , Math.max(2,xoff))+getpagescrollx(), my+yoff+((!AT.ns6)?getpagescrolly():0));

if(!mousefollow)AT.oktomove=false;

}
 

  AT.navtxt=(AT.ns4)?document.layers['navtxt']:(AT.ie4)?document.all['navtxt']:(AT.w3c)?document.getElementById('navtxt'):null;

  getboxwidth();

  getboxheight();

  getwindowdims();

  if(AT.ie4||AT.ie5&&dofade)AT.navtxt.style.filter="alpha(opacity=100)";

  AT.navtxt.onmouseover=function(){

  if(!mousefollow)clearTimeout(AT.dy);

  }

  AT.navtxt.onmouseout=function(){

  if(!mousefollow)AT.dy=setTimeout('hideAlttxt()',hideDelay);

  }

  if(AT.ns4)document.captureEvents(Event.MOUSEMOVE);

  document.onmousemove=moveobj;

  window.onresize=getwindowdims;
 

window.onload=function(){

	sidemenuinit();

	alttxtinit();

}

Open in new window

0
 
LVL 41

Accepted Solution

by:
HonorGod earned 500 total points
ID: 21803669
ok, the problem is the way in which you created the init functions.

sidemenuinit() should be what used to be the window.onload for that file.
and alttxtinit() should be what used to be the window.onload for the other file.

So, edit sidemenu.js and change:
--------------------------------------------------
function init(){
if(NS4){
smenu=document.smenu;
movexto(-menuwidth-2);
smenu.visibility="show";
}
--------------------------------------------------

To:
--------------------------------------------------
function sidemenuinit(){
if(NS4){
smenu=document.smenu;
movexto(-menuwidth-2);
smenu.visibility="show";
}
--------------------------------------------------

and remove the:
--------------------------------------------------
window.onload=init;
--------------------------------------------------

In the alltxt file, change:
--------------------------------------------------
window.onload=function(){
  AT.navtxt=(AT.ns4)?document.layers['navtxt']:(AT.ie4)?document.all['navtxt']:(AT.w3c)?document.getElementById('navtxt'):null;
  getboxwidth();
  getboxheight();
  getwindowdims();
  if(AT.ie4||AT.ie5&&dofade)AT.navtxt.style.filter="alpha(opacity=100)";
  AT.navtxt.onmouseover=function(){
  if(!mousefollow)clearTimeout(AT.dy);
  }
  AT.navtxt.onmouseout=function(){
  if(!mousefollow)AT.dy=setTimeout('hideAlttxt()',hideDelay);
  }
  if(AT.ns4)document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove=moveobj;
  window.onresize=getwindowdims;
}
--------------------------------------------------

To be:
--------------------------------------------------
function alltxtinit() {
  AT.navtxt=(AT.ns4)?document.layers['navtxt']:(AT.ie4)?document.all['navtxt']:(AT.w3c)?document.getElementById('navtxt'):null;
  getboxwidth();
  getboxheight();
  getwindowdims();
  if(AT.ie4||AT.ie5&&dofade)AT.navtxt.style.filter="alpha(opacity=100)";
  AT.navtxt.onmouseover=function(){
  if(!mousefollow)clearTimeout(AT.dy);
  }
  AT.navtxt.onmouseout=function(){
  if(!mousefollow)AT.dy=setTimeout('hideAlttxt()',hideDelay);
  }
  if(AT.ns4)document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove=moveobj;
  window.onresize=getwindowdims;
}
--------------------------------------------------

Then, your window.onload can be:
--------------------------------------------------
window.onload=function(){
      sidemenuinit();
      alltxtinit();
}
--------------------------------------------------
0
 

Author Comment

by:gjpitt
ID: 21803862
Wonderful and many many thanks for the solution. It works!
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21804181
Excellent news.  I'm very happy to hear it.  Thanks for the grade & points.

Good luck, and have a great day.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now