Change menu items out of an iframe

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
columbus21
Beginner
Beginner
Posts: 2
Joined: Mon Jan 09, 2006 1:17 pm

Change menu items out of an iframe

Post by columbus21 »

Hi,

does anybody know how to change menu items out of an iframe?

I have one single page containing the menu and two iframes. I want to change some menu items when a certain page is loaded in one of these iframes.

I'm using the following custom function to change items - it works if used directly in the main page ...

Code: Select all

function mm_changeItemProperty(menuName, itemName, codeRef, newValue, updateDisplay) {

  menuName = menuName.toLowerCase();

  for (i=0; i<_mi.length; i++)

    if (_mi[i][1].replace(/\&nbsp\;/ig,' ') == itemName && _m[_mi[i][0]][1] == menuName) break;

  if (i == _mi.length) return;

  _mi[i][codeRef] = newValue;

  if (updateDisplay) BDMenu(_mi[i][0]);

}
Thanks for help!
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hello,

So, if I understand correctly: The mm_changeItemProperty() function is defined in the main page and the menu that you want to change is also in the main page, but you want to call mm_changeItemProperty() from a page that's loaded into an iframe. Correct?

Assuming that the <iframe> is defined within the main page, then you should be able to call the function by prepending parent. to the function name. Like so:

Code: Select all

parent.mm_changeItemProperty(params....);
You're telling the browser, "go to the parent page and run the function named mm_changeItemProperty() contained within that page." Function parameters are passed as usual, but if you pass a variable, then you are passing the value of the variable in the iframe page, not in the parent page.

Hope that made sense, and hope it helps.

Kevin
columbus21
Beginner
Beginner
Posts: 2
Joined: Mon Jan 09, 2006 1:17 pm

Post by columbus21 »

That's it - of course! :oops:

Thanks, Kevin!
Post Reply