Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:18
Change menu items out of an iframe
Poster: columbus21
Dated: Monday January 9 2006 - 12:47:24 GMT
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:
function mm_changeItemProperty(menuName, itemName, codeRef, newValue, updateDisplay) {
menuName = menuName.toLowerCase();
for (i=0; i<_mi.length; i++)
if (_mi[i][1].replace(/\ \;/ig,' ') == itemName && _m[_mi[i][0]][1] == menuName) break;
if (i == _mi.length) return;
_mi[i][codeRef] = newValue;
if (updateDisplay) BDMenu(_mi[i][0]);
}
menuName = menuName.toLowerCase();
for (i=0; i<_mi.length; i++)
if (_mi[i][1].replace(/\ \;/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!
Poster: kevin3442
Dated: Wednesday January 11 2006 - 0:54:49 GMT
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:
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