[thelist] Javascript help required!

Richard Bennett richard.bennett at skynet.be
Sun May 26 07:05:01 CDT 2002


Hi,
<----- Original Message -----
<From: "David Rafferton" <david at vidmandesign.com>
<See it here-
<http://www.vidmandesign.com/entertainmentcareers/frameset.html

<The tricky thing is that I want the rollovers to stay in there "over"
<state upon clicking them

Should be pretty simple right?
Normally I would simply suggest how to tweak the code to get this to work,
but in this case you're having trouble with this because the site
architecture and Dreamweaver's spaghetti-code are complicating things for
you.

Sure you can get it to work like this, but I think a site architecture
rethink might make things simpler in the long-run.
(I mean avoiding frames and javascript navigation, something like Google
does (the tabs))

If someone clicks "job listings", does a page load, or do they have to click
something on the submenu?
If a page loads, why not include the submenu, or the whole menu on this
page?
If a page doesn't load, why not? that means 2 clicks are needed to load each
page.

Anyway, you probably just want to get it working as it is, so try this:

Add:

var tabId,tabSrc,lastSrc

function setTab(id){
 if(tabId)document.images[tabId].src=tabSrc
 tabId=id
 tabSrc=lastSrc
 document.MM_sr=null
}

and replace MM_swapImage with this version:

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&&a[i]!=tabId){
       document.MM_sr[j++]=x;
       lastSrc=x.src
       if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
      }
   }
}

Then add "setTab(this.name);" to each main menu item's onmousedown event,
like this:

onmousedown="setTab(this.name);MM_showHideLayers('home','','show','joblistin
gs','','hide','jobtips','','hide','industryresources','','hide')"

That does what you want for the main menu.
You are going to find all kinds of cross-browser problems as you go though
(see above comments)

Cheers,
Richard.




More information about the thelist mailing list