Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Javascript menu in header file


kapturedsoul

Recommended Posts

I am trying to put in a javascript acitvated menu in header.php

 

When I test the code on a page that just has the javascript and menu table everything works fine. When I put it in the header.php file, I get Error:Object Expected when it comes to the MM_swapImage function.

 

here is the code... I just added the javascript to the very top

then added a body tag and put the menu inside of it. I highlighted everything I added in BLUE. I greatly appreciate any help.

 

 

[COLOR=blue]
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v3.0
 var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;parent.frame
s.length) {
   d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;d.all) x=d.all[n]; for (i=0;!x&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;d.layers&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
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];}}
}

//-->
</script>[/COLOR]

<?php
/*
 $Id: header.php,v 1.42 2003/06/10 18:20:38 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// check if the 'install' directory exists, and warn of its existence
 if (WARN_INSTALL_EXISTENCE == 'true') {
   if (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/install')) {
     $messageStack->add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning');
   }
 }

// check if the configure.php file is writeable
 if (WARN_CONFIG_WRITEABLE == 'true') {
   if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) && (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) {
     $messageStack->add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning');
   }
 }

// check if the session folder is writeable
 if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') {
   if (STORE_SESSIONS == '') {
     if (!is_dir(tep_session_save_path())) {
       $messageStack->add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning');
     } elseif (!is_writeable(tep_session_save_path())) {
       $messageStack->add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning');
     }
   }
 }

// check session.auto_start is disabled
 if ( (function_exists('ini_get')) && (WARN_SESSION_AUTO_START == 'true') ) {
   if (ini_get('session.auto_start') == '1') {
     $messageStack->add('header', WARNING_SESSION_AUTO_START, 'warning');
   }
 }

 if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') && (DOWNLOAD_ENABLED == 'true') ) {
   if (!is_dir(DIR_FS_DOWNLOAD)) {
     $messageStack->add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning');
   }
 }

 if ($messageStack->size('header') > 0) {
   echo $messageStack->output('header');
 }
?>
[COLOR=blue]<body bgcolor="#ffffff" onLoad="MM_preloadImages('includes/DG_text2_4_r2_c1.gif','includes/DG_text2_4_r2_c1_f4.gif','includes/DG_text2_4_r2_c1_f3.gif','includes/DG_text2_4_r2_c1_f2.gif');">
<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="650">
<!-- fwtable fwsrc="menu/DG_text2.png" fwbase="includes/DG_text2_4.gif" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
 <tr>
  <td><img src="includes/spacer.gif" width="650" height="1" border="0"></td>
  <td><img src="includes/spacer.gif" width="1" height="1" border="0"></td>
 </tr>

 <tr>
  <td><img name="DG_text2_4_r1_c1" src="includes/DG_text2_4_r1_c1.gif" width="650" height="61" border="0"></td>
  <td><img src="includes/spacer.gif" width="1" height="61" border="0"></td>
 </tr>
 <tr>
  <td><img name="DG_text2_4_r2_c1" src="includes/DG_text2_4_r2_c1.gif" width="650" height="66" border="0" usemap="#m_DG_text2_4_r2_c1"></td>
  <td><img src="includes/spacer.gif" width="1" height="66" border="0"></td>
 </tr>
 <tr>
  <td bgcolor="#ffffff"><img src="includes/spacer.gif" width="650" height="73" border="0"></td>
  <td><img src="includes/spacer.gif" width="1" height="73" border="0"></td>
 </tr>
<map name="m_DG_text2_4_r2_c1">
<area shape="rect" coords="307,6,379,38" href="www.dixiegraphics.net/catalog" onMouseOut="MM_swapImage('DG_text2_4_r2_c1','','includes/DG_text2_4_r2_c1.gif',1);"  onMouseOver="MM_swapImage('DG_text2_4_r2_c1','','includes/DG_text2_4_r2_c1.gif',1);"  >
<area shape="rect" coords="551,6,642,39" href="#" onMouseOut="MM_swapImage('DG_text2_4_r2_c1','','includes/DG_text2_4_r2_c1.gif',1);"  onMouseOver="MM_swapImage('DG_text2_4_r2_c1','','includes/DG_text2_4_r2_c1_f4.gif',1);"  >
<area shape="rect" coords="456,6,548,39" href="#" onMouseOut="MM_swapImage('DG_text2_4_r2_c1','','includes/DG_text2_4_r2_c1.gif',1);"  onMouseOver="MM_swapImage('DG_text2_4_r2_c1','','includes/DG_text2_4_r2_c1_f3.gif',1);"  >
<area shape="rect" coords="381,6,453,38" href="catalog/index.php?cPath=27" target="_prints" title="Prints" alt="Prints" onMouseOut="MM_swapImage('DG_text2_4_r2_c1','','includes/DG_text2_4_r2_c1.gif',1);"  onMouseOver="MM_swapImage('DG_text2_4_r2_c1','','includesDG_text2_4_r2_c1_f2.gif',1);"  >
</map>
</table>[/COLOR]



 
<table border="0" width="100%" cellspacing="0" cellpadding="1">
 <tr class="headerNavigation">
   <td class="headerNavigation">  <?php echo $breadcrumb->trail(' » '); ?></td>
   <td align="right" class="headerNavigation"><?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LOGOFF; ?></a>  |  <?php } ?><a href="<?php echo tep_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a>  |  <a href="<?php echo tep_href_link(FILENAME_SHOPPING_CART); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a>  |  <a href="<?php echo tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CHECKOUT; ?></a>   </td>
 </tr>
</table>
<?php
 if (isset($HTTP_GET_VARS['error_message']) && tep_not_null($HTTP_GET_VARS['error_message'])) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr class="headerError">
   <td class="headerError"><?php echo htmlspecialchars(urldecode($HTTP_GET_VARS['error_message'])); ?></td>
 </tr>
</table>
<?php
 }

 if (isset($HTTP_GET_VARS['info_message']) && tep_not_null($HTTP_GET_VARS['info_message'])) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr class="headerInfo">
   <td class="headerInfo"><?php echo htmlspecialchars($HTTP_GET_VARS['info_message']); ?></td>
 </tr>
</table>

<?php
 }
?>
[COLOR=blue]</body>[/COLOR]

Link to comment
Share on other sites

I fixed it.

 

The javascript had to be added in on the index.php page...and also I should have not put the body tags in the header.php page.

 

I tried the javascript in the index.php page earlier..but now it decided to work..ohhh well!!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...