Click to See Complete Forum and Search --> : [RESOLVED] I'm trying to include 2 JS in my page


Matpatnik
06-11-2006, 11:07 PM
Hi guys,

My knowledge to JavaScript is very limited so I used dreamweaver and fireworks to help me with the coding while i'm learning the code. The Problem I'm facing right now is that I have 2 diferents JavaScript code in my page, each one individualy work pretty fine but once I try to incorporat both together in the same page the second code do exacly like the first one.

Here the page
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<link href="test.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
<!--
function galleryLoadMenus() {
if (window.mm_menu_0611183650_0) return;
window.mm_menu_0611183650_0 = new Menu("root",150,20,"Verdana, Arial, Helvetica, sans-serif",14,"#333300","#ff0000","#cccc66","#33ff99","left","middle",3,0,500,0,0,true,false,true,0,false,false);
mm_menu_0611183650_0.addMenuItem("Full-Size&nbsp;Stone","location='FullSize/FullSizeStone01.htm'");
mm_menu_0611183650_0.addMenuItem("Flagstone","location='Gallery/gallery-page1.htm'");
mm_menu_0611183650_0.addMenuItem("Gallery","location='Flagstone/flagstone-page1.htm'");
mm_menu_0611183650_0.bgImageUp="popUp/mmmenu1_150x20_up.gif";
mm_menu_0611183650_0.bgImageOver="popUp/mmmenu1_150x20_over.gif";
mm_menu_0611183650_0.hideOnMouseOut=true;
mm_menu_0611183650_0.bgColor='#555555';

mm_menu_0611183650_0.writeMenus();
} // galleryLoadMenus()
//-->
</script>
<script language="JavaScript">
<!--
function projectLoadMenus() {
if (window.mm_menu_0611183650_0) return;
window.mm_menu_0611183650_0_1 = new Menu("House&nbsp;Facings",150,20,"Verdana, Arial, Helvetica, sans-serif",14,"#333300","#ff0000","#cccc66","#33ff99","left","middle",3,0,500,0,0,true,false,true,0,false,false);
mm_menu_0611183650_0_1.addMenuItem("Natural&nbsp;Stone","location='HouseFacingNatural/HfacingN01.htm'");
mm_menu_0611183650_0_1.addMenuItem("Manufactured","location='HouseFacingMatufactured/HfacingM01.htm'");
mm_menu_0611183650_0_1.bgImageUp="popUp/mmmenu1_150x20_up.gif";
mm_menu_0611183650_0_1.bgImageOver="popUp/mmmenu1_150x20_over.gif";
mm_menu_0611183650_0_1.hideOnMouseOut=true;
mm_menu_0611183650_0_1.bgColor='#555555';
window.mm_menu_0611183650_0_2 = new Menu("Fireplace&nbsp;Facings",150,20,"Verdana, Arial, Helvetica, sans-serif",14,"#333300","#ff0000","#cccc66","#33ff99","left","middle",3,0,500,0,0,true,false,true,0,false,false);
mm_menu_0611183650_0_2.addMenuItem("Natural&nbsp;Stone","location='Project/FfacingN.htm'");
mm_menu_0611183650_0_2.addMenuItem("Manufactured","location='Project/FfacingM.htm'");
mm_menu_0611183650_0_2.bgImageUp="popUp/mmmenu1_150x20_up.gif";
mm_menu_0611183650_0_2.bgImageOver="popUp/mmmenu1_150x20_over.gif";
mm_menu_0611183650_0_2.hideOnMouseOut=true;
mm_menu_0611183650_0_2.bgColor='#555555';
window.mm_menu_0611183650_0 = new Menu("root",150,20,"Verdana, Arial, Helvetica, sans-serif",14,"#333300","#ff0000","#cccc66","#33ff99","left","middle",3,0,500,0,0,true,false,true,0,false,false);
mm_menu_0611183650_0.addMenuItem(mm_menu_0611183650_0_1,"location='Project/index.html'");
mm_menu_0611183650_0.addMenuItem(mm_menu_0611183650_0_2,"location='Project/index.html'");
mm_menu_0611183650_0.bgImageUp="popUp/mmmenu1_150x20_up.gif";
mm_menu_0611183650_0.bgImageOver="popUp/mmmenu1_150x20_over.gif";
mm_menu_0611183650_0.hideOnMouseOut=true;
mm_menu_0611183650_0.childMenuIcon="popUp/arrows.gif";
mm_menu_0611183650_0.bgColor='#555555';

mm_menu_0611183650_0.writeMenus();
} // mmLoadMenus()
//-->
</script>
<script language="JavaScript1.2" src="popUp/Gallery_menu.js"></script>
<script language="JavaScript1.2" src="popUp/Project_menu.js"></script>
</head>
<body>
<table width="866" border="0">
<tr>
<th id="BG"> <SCRIPT language="JavaScript1.2">projectLoadMenus();</SCRIPT>
<A href="Project/" onMouseOut="MM_startTimeout();" onMouseOver="MM_showMenu(window.mm_menu_0611183650_0,150,0,null,'Project_Layer');"><IMG name="Project_Layer" src="popUp/Project_Layer.gif" width="150" height="18" border="0" alt="Project"></A></th>
</tr>
<tr>
<th id="BG"> <SCRIPT language="JavaScript1.2">galleryLoadMenus();</SCRIPT>
<A href="Gallery/" onMouseOut="MM_startTimeout();" onMouseOver="MM_showMenu(window.mm_menu_0611183650_0,150,0,null,'Gallery_Layer');"><IMG name="Gallery_Layer" src="popUp/Gallery_Layer.gif" width="150" height="18" border="0" alt="Gallery"></A></th>
</tr>
</table>
</body>
</html>

I you can tell me what's wrong in this page with a quick explanation, I think that will help me in the learning process.

*Oh yah, it's a pop up menu :)

Thank you very much
Mat

phpnovice
06-11-2006, 11:45 PM
Search all of your code for occurrences of onload and post back here with what you find.

backwoods
06-12-2006, 12:06 AM
I am not that good with Java myself, but you have two different menus and it appears to me that you are using the same variables for both menus. Try changing in th gallery menu the mm_menu_ to mn_menu_
It's worth a try. I have had this happen to me in the past.

Matpatnik
06-12-2006, 12:36 PM
Search all of your code for occurrences of onload and post back here with what you find.
Hi phpnovice, I didn't find any onload code in the script is that normal?

Try changing in th gallery menu the mm_menu_ to mn_menu_
It's worth a try. I have had this happen to me in the past.
Hi backwoods, I tryed to change mm_ to mn_ but it stop working.
yes it's 2 differents pop up menu, I want to keep that way because I like the look it give to the menu

phpnovice
06-12-2006, 12:53 PM
Hi phpnovice, I didn't find any onload code in the script is that normal?
That just eliminates the most common cause for conflicts -- which is good. However, that is also the easiest cause to fix. :( The other most common cause is, as mentioned, using duplicate object and/or global variable names between the two scripts. Are these scripts actually the same script but you're trying to use two copies of it at the same time and in the same page?

Matpatnik
06-12-2006, 01:22 PM
I'm using 2 diferents script on the same page but they are using the same externat file. I tried to use 2 diferent externat file but it's eather it dosen't work or it do the same thing then the first one. I tried to rename every mm to mn but but it just make the script unavailable :(

here is 2 links of what it look like alone: 01 (http://matpatnik.com/01.htm), 02 (http://matpatnik.com/02.htm)

and what it look like together: 03 (http://matpatnik.com/03.htm)

phpnovice
06-12-2006, 03:47 PM
Basically, without hiring somebody to fix the problem for you, you're going to need an Interactive JavaScript Debugger to step through and check each assignment and object reference to identify where the conflict lies. There is a free one for downloading for Firefox (Venkman JavaScript Debugger). For IE, there is the MS Script Debugger.

Matpatnik
06-12-2006, 08:13 PM
Thank you for your time :)

I'll see what i can do with the debugger and maybe I'll do it all in once

Oh by the way do you know where I can get for free or learn a way to do that kind of pop up menu? it seems very complicated

thx again
Mat

phpnovice
06-12-2006, 10:10 PM
Have you tried Google? There are all kinds of tutorials on the Internet.

Cheers.