Results 1 to 6 of 6

Thread: About jsDOMenuBar

  1. #1
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default About jsDOMenuBar

    1) Script Title: jsDOMenuBar

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ubar/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ú

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    <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>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks a lot John. You make my day!
    Blessings

  4. #4
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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ú

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Use top instead of parent.

    Code:
    <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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You really are the best!!!!!!.. Unfortunately I'm married
    Have a nice weekend

    Regards from Lima, Perú

    MC

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •