Can we use first and third party cookies and web beacons to understand our audience, and to tailor promotions you see?

java script problem

I am upgrading my site from drupal 4.7x to 5.1x
all things are done properly except following java script code is not running

this code i used into page.tpl.php into my drupal 4.7x site
If I want to use same functions into my drupal 5.1x site
what I have to do?
here I used bluemarine theme page.tpl.php,I declare #primary-nav into my style.css

Into style.css
ul#primary-nav,
ul#primary-nav ul {
margin: 0;
padding: 0;
width: 160px; /* Width of Menu Items */
background: #FAFAF0; /* IE6 Bug */
font-size: 100%;
}
ul#primary-nav li {
position: relative;
list-style: none;
}
Into page.tpl.php

var navItems = document.getElementById("primary-nav").getElementsByTagName("li"); for (var i=0; i < navItems.length; i++) { if(navItems[i].className == "expanded") { navItems[i].onmouseover=function() {this.className += " over"; } navItems[i].onmouseout=function() { this.className = "expanded"; } } }

I already read changes which are used for js of 5.1
but I can't get proper output.

Comments

panis’s picture

post your entire page.tpl.php. Are you getting javascript errors?
you could rely on jquery to do the above too.

<script>
$(document).load( 

function() {
     $('#primary-nav').children('li.expanded').hover(function () { $(this).addClass("over"); }, function () { $(this).removeClass("over");} );
  });
</script>

of course all this may work only if thr primary-nav exists on you page. If you have firefox and its firebug extension debugging this would be straightforward.

divyeshvk’s picture

Thank you for your replay.
but my problem is not solved yet
Here is my page.tpl.php,This is I used into my drupal 4.7 site,same theme i can use in drupal 5.1


print $language " xml:lang=" print $language ">

print $head_title
print $head
print $styles
print $script

/* Needed to avoid Flash of Unstyle Content in IE */


if ($sidebar_left) {

}

if ($mission) {
print $mission

}

print $breadcrumb

print $title
print $tabs

print $help
if ($messages != ""){

print $messages

}
print $content;

dwees’s picture

I've implemented these menus on about 10 different sites without difficulty. The biggest issue is making sure that the container div that your menus are in has the right ID.

You are currently looking in 'primary-nav' for your menu, is that where it is? It might have changed its container wrapper with the change of theme.

Dave
My site: http://www.unitorganizer.com/myblog

divyeshvk’s picture

Thank you for your reply.

#primary-nav into my style.css of blumarine(Ver drupal-4.7)

same theme I used for my Drupal 5.1 upgradation.theme placed into
drupal-5.1 >> sites >> all >>themes >> mytheme(changing theme name from bluemarine to mytheme)

I already change my code
as follow

$(document).load.(function(){ var navItems = document.getElementById("#primary-nav").getElementsByTagName("#li"); for (var i=0; i < navItems.length; i++) { if(navItems[i].className == "expanded") { navItems[i].onmouseover=ready(function() { $(this).className += " over"; }) navItems[i].onmouseout=ready(function() { $(this).className = "expanded"; }) } } });