PDA

View Full Version : About jsDOMenuBar



mariaclaudia
03-17-2012, 07:43 PM
1) Script Title: jsDOMenuBar

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/jsdomenubar/index.htm

3) Describe problem:
Hi, this is my very first post here. Please, sorry my grammar. This script works fine but I have one question. I have a page MAIN.ASP with a iframe. The menu is on MAIN.ASP and when I click any place in MAIN.ASP the menu is close or hidden. That's all right, but if I click any place inside the iframe, the menu don't close or hide.

I know that's normal because the click is not in the page where the script is, but, how can I do to close the menu when I click inside the iframe?. I read the doc in the JS files but I do not understand javascript very well.

Sorry my grammar please.
Regards from Lima, Perú

jscheuer1
03-18-2012, 06:32 AM
Greetings,

For this to work both pages must be on the same domain. If so, just put this script in the head of the page inside the iframe:


<script type="text/javascript">
;(function(){
function clickfunction(e){
e = e || event;
parent.document.onclick(e);
};

if (document.addEventListener){
document.addEventListener('click', clickfunction, false);
}
else if (document.attachEvent){
document.attachEvent('onclick', clickfunction);
}
})();
</script>

mariaclaudia
03-18-2012, 12:16 PM
Thanks a lot John. You make my day!
Blessings

mariaclaudia
03-21-2012, 10:01 PM
One question.. I wonder how can I do if is an iframe inside a iframe. I mean, your script works if is a single iframe, but, if I have a iframe inside a iframe? How can I do it?

Thanks in advance.
Sorry my grammar
Regards from Lima, Perú

jscheuer1
03-22-2012, 04:18 AM
Use top instead of parent.


<script type="text/javascript">
;(function(){
function clickfunction(e){
e = e || event;
top.document.onclick(e);
};

if (document.addEventListener){
document.addEventListener('click', clickfunction, false);
}
else if (document.attachEvent){
document.attachEvent('onclick', clickfunction);
}
})();
</script>

That will work for the page in the middle as well.

mariaclaudia
03-23-2012, 07:47 PM
You really are the best!!!!!!.. Unfortunately I'm married
Have a nice weekend

Regards from Lima, Perú

MC