Results 1 to 4 of 4

Thread: Open Link from Modal into Parent and Close Modal

  1. #1
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Open Link from Modal into Parent and Close Modal

    1) Script Title: DHTML Modal window v1.1

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...dhtmlmodal.htm

    3) Describe problem:
    I have got the code into my web page so that the modal window opens when a link is clicked. The modal window loads another page via an iframe. The page that opens in the modal window contains links. What I want to do is this: when the user clicks on a link in the modal window - load that linked page into the parent window and close the modal window. Is there a simple way to do this?

    Thanks in advance for your help!

  2. #2
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Here's my code:

    A little more info --

    The use of the modal window is for a web visitor to select their region and be taken to a specific homepage based on that selection.

    Here is the code I have that opens the modal window:

    <font size="-2"><b>Worldwide</b> [<a href="#" onClick="selectregion=dhtmlmodal.open('regionbox', 'iframe', 'region_select2.html', 'Select Your Region & Language', 'width=410px,height=300px,center=1,resize=0,scrolling=1'); return false">Change</a>]</font>

    Here is the code for one of the links that I have in the page (region_select2.html) that opens in the modal window:

    <a href="north_america.aspx" onClick="selectregion.close(); return false"><font size="-1">North America [English]</font></a>

    Right now when I click on the link inside the modal window the new page (north_america.aspx) is loaded into the modal. I want to have it load in the parent (hidden behind the veil) and automatically close the modal.

    I'm new to this forum so thanks again for reading through this. I'm hoping someone can help me sort this out.

  3. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    In general you can access the main parent window from inside the document of the modal window by using the JavaScript keyword "parent". So to load the link in question inside the main window while closing the modal window, you can try:

    Code:
    <a href="north_america.aspx" onClick="parent.selectregion.close(); parent.location=this.href; return false"><font size="-1">North America [English]</font></a>
    DD Admin

  4. The Following User Says Thank You to ddadmin For This Useful Post:

    goodness (04-07-2009)

  5. #4
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks! I'll give that a try.

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
  •