PDA


View Full Version : onmouseover not working for one cell


Marris
08-06-2005, 10:26 PM
I am trying to make a graphic navbar for both the forum and the portal using rollover images. I have duplicated all the functionality of the default vB navbar in both the portal and forum. Everything works except...

My problem is the 'Search' button rollover image is not displaying on the portal page. The same exact code does work and display all rollover images including 'Search' on the navbar displayed on forum pages, just not on the portal. However, all the other menu rollovers on the portal are working correctly.

Please have a look and let me know if you can spot the problem:

<td id="navbar_search">
<a href="$vboptions[bburl]/search.php?$session[sessionurl]" accesskey="4"
onmouseover="changeImages('search', '$vboptions[bburl]/images/search-over.gif'); return true;"
onmouseout="changeImages('search', '$vboptions[bburl]/images/search.gif'); return true;"
onmousedown="changeImages('search', '$vboptions[bburl]/images/search-over.gif'); return true;"
onmouseup="changeImages('search', '$vboptions[bburl]/images/search-over.gif'); return true;"><img name="search" src="$vboptions[bburl]/images/search.gif" width="74" height="20" border="0" alt=""></a><script type="text/javascript">vbmenu_register("navbar_search", 1);</script></td>

I'm wondering if it might have to do with a conflict between the rollover and the vB search popup, but the same code does rollover within the forum and the popup works on the forum and portal.

For comparison, here are a couple cells that work correctly on the portal and in the forum:

<if condition="$bbuserinfo['userid']">
<td id="usercptools">
<a href="#usercptools"
onmouseover="changeImages('links', '$vboptions[bburl]/images/links-over.gif'); return true;"
onmouseout="changeImages('links', '$vboptions[bburl]/images/links.gif'); return true;"
onmousedown="changeImages('links', '$vboptions[bburl]/images/links-over.gif'); return true;"
onmouseup="changeImages('links', '$vboptions[bburl]/images/links-over.gif'); return true;">
<img name="links" src="$vboptions[bburl]/images/links.gif" width="95" height="20" border="0" alt=""></a><script type="text/javascript">vbmenu_register("usercptools", 1); </script></td>
</if>

And another working example:

<if condition="$show['registerbutton']">
<td>
<a href="$vboptions[bburl]/register.php?$session[sessionurl]"
onmouseover="changeImages('register', '$vboptions[bburl]/images/register-over.gif'); return true;"
onmouseout="changeImages('register', '$vboptions[bburl]/images/register.gif'); return true;"
onmousedown="changeImages('register', '$vboptions[bburl]/images/register-over.gif'); return true;"
onmouseup="changeImages('register', '$vboptions[bburl]/images/register-over.gif'); return true;">
<img name="register" src="$vboptions[bburl]/images/register.gif" width="71" height="20" border="0" alt=""></a></td>
</if>

And the Java script:

function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}

var preloadFlag = false;
function preloadImages() {
if (document.images) {
forum_over = newImage("$vboptions[bburl]/images/forum-over.gif");
register_over = newImage("$vboptions[bburl]/images/register-over.gif");
main_over = newImage("$vboptions[bburl]/images/main-over.gif");
cp_over = newImage("$vboptions[bburl]/images/cp-over.gif");
donate_over = newImage("$vboptions[bburl]/images/donate-over.gif");
faq_over = newImage("$vboptions[bburl]/images/faq-over.gif");
cal_over = newImage("$vboptions[bburl]/images/cal-over.gif");
gallery_over = newImage("$vboptions[bburl]/images/gallery-over.gif");
newposts_over = newImage("$vboptions[bburl]/images/newposts-over.gif");
search_over = newImage("$vboptions[bburl]/images/search-over.gif");
links_over = newImage("$vboptions[bburl]/images/links-over.gif");
logout_over = newImage("$vboptions[bburl]/images/logout-over.gif");
preloadFlag = true;
}
}

Any advice is greatly appreciated.

Brian
08-07-2005, 01:45 PM
Can you post a link to your site so I can see the problem in action?

Marris
08-08-2005, 01:13 AM
Thanks for the offer, but I'm still only testing on my local machine. Your post did encourage to have another look though and I tracked down the problem.

There was a conflict with the CMPS Search Module:

<form action="$vboptions[bburl]/search.php" method="post" name="search">

name="search" was the same identifier that I had used for my rollover Search button. The Javascript was using that "search" identifier to swap images and the Search module's use of that name prevented the mouse states from registering on that one button.

I fixed it by changing the rollover name.

Brian
08-08-2005, 01:52 PM
Glad you got it worked out. :)