music_lp90 Posted May 22, 2007 Share Posted May 22, 2007 Hi, I'm trying to create one page for my main navigation that I can include on every page by using the php include function. This way if I need to make changes to the navigation, I can do it in one place and not have to change it on every page. My problem is I can't figure out how to make the button stay on its down state for the page it's on.This is the navigation code: <script language="JavaScript" type="text/JavaScript"><!--function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_nbGroup(event, grpName) { //v6.0 var i,img,nbArr,args=MM_nbGroup.arguments; if (event == "init" && args.length > 2) { if ((img = MM_findObj(args[2])) != null && !img.MM_init) { img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src; if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array(); nbArr[nbArr.length] = img; for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) { if (!img.MM_up) img.MM_up = img.src; img.src = img.MM_dn = args[i+1]; nbArr[nbArr.length] = img; } } } else if (event == "over") { document.MM_nbOver = nbArr = new Array(); for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) { if (!img.MM_up) img.MM_up = img.src; img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up); nbArr[nbArr.length] = img; } } else if (event == "out" ) { for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; } } else if (event == "down") { nbArr = document[grpName]; if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; } document[grpName] = nbArr = new Array(); for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) { if (!img.MM_up) img.MM_up = img.src; img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up; nbArr[nbArr.length] = img; } }}//--></script></head><body onLoad="MM_preloadImages('images/navigation/top_nav/home_over.gif','images/navigation/top_nav/explore_over.gif','images/navigation/top_nav/info_events_over.gif','images/navigation/top_nav/reaching_out_over.gif','images/navigation/top_nav/programs_over.gif','images/navigation/top_nav/contact_over.gif')"><table border="0" cellpadding="0" cellspacing="0"> <tr> <td><a href="index.php" target="_top" onClick="MM_nbGroup('down','group1','home_up','images/navigation/top_nav/home_over.gif',1)" onMouseOver="MM_nbGroup('over','home_up','images/navigation/top_nav/home_over.gif','images/navigation/top_nav/home_over.gif',1)" onMouseOut="MM_nbGroup('out')"><img src="images/navigation/top_nav/home_up.gif" alt="Home" name="home_up" width="99" height="24" border="0" onload=""></a></td> <td><a href="explore.php" target="_top" onClick="MM_nbGroup('down','group1','explore_up','images/navigation/top_nav/explore_over.gif',1)" onMouseOver="MM_nbGroup('over','explore_up','images/navigation/top_nav/explore_over.gif','images/navigation/top_nav/explore_over.gif',1)" onMouseOut="MM_nbGroup('out')"><img src="images/navigation/top_nav/explore_up.gif" alt="Explore" name="explore_up" width="115" height="24" border="0" onload=""></a></td> <td><a href="info.php" target="_top" onClick="MM_nbGroup('down','group1','info_events_up','images/navigation/top_nav/info_events_over.gif',1)" onMouseOver="MM_nbGroup('over','info_events_up','images/navigation/top_nav/info_events_over.gif','images/navigation/top_nav/info_events_over.gif',1)" onMouseOut="MM_nbGroup('out')"><img src="images/navigation/top_nav/info_events_up.gif" alt="Info and Events" name="info_events_up" width="128" height="24" border="0" onload=""></a></td> <td><a href="reaching.php" target="_top" onClick="MM_nbGroup('down','group1','reaching_out_up','images/navigation/top_nav/reaching_out_over.gif',1)" onMouseOver="MM_nbGroup('over','reaching_out_up','images/navigation/top_nav/reaching_out_over.gif','images/navigation/top_nav/reaching_out_over.gif',1)" onMouseOut="MM_nbGroup('out')"><img src="images/navigation/top_nav/reaching_out_up.gif" alt="Reaching Out" name="reaching_out_up" width="128" height="24" border="0" onload=""></a></td> <td><a href="programs.php" target="_top" onClick="MM_nbGroup('down','group1','programs_up','images/navigation/top_nav/programs_over.gif',1)" onMouseOver="MM_nbGroup('over','programs_up','images/navigation/top_nav/programs_over.gif','images/navigation/top_nav/programs_over.gif',1)" onMouseOut="MM_nbGroup('out')"><img src="images/navigation/top_nav/programs_up.gif" alt="Programs" name="programs_up" width="120" height="24" border="0" onload=""></a></td> <td><a href="contact.php" target="_top" onClick="MM_nbGroup('down','group1','contact_up','images/navigation/top_nav/contact_over.gif',1)" onMouseOver="MM_nbGroup('over','contact_up','images/navigation/top_nav/contact_over.gif','images/navigation/top_nav/contact_over.gif',1)" onMouseOut="MM_nbGroup('out')"><img src="images/navigation/top_nav/contact_up.gif" alt="Contact" name="contact_up" width="87" height="24" border="0" onload=""></a></td> </tr></table> And I simply include this by going <?php include "navigation.php"; ?>Thanks for any help, I really appreciate it! Link to comment Share on other sites More sharing options...
justsomeguy Posted May 22, 2007 Share Posted May 22, 2007 To determine which page you're on, either have a variable in the parent page that will define which page it is (or which menu button to activate), or look at the $_SERVER['SCRIPT_NAME'] variable. Link to comment Share on other sites More sharing options...
music_lp90 Posted May 23, 2007 Author Share Posted May 23, 2007 Thanks, that works great. I used the $_SERVER['SCRIPT_NAME'] that you suggested. This is so much easier to add to new pages, thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.