Results 1 to 4 of 4

Thread: DHTML Window widget - Open a window from an iframe

  1. #1
    Join Date
    Nov 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default DHTML Window widget - Open a window from an iframe

    1) Script Title:
    DHTML Window widget

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

    3) Describe problem:

    Is there a way to have a window (using an iframe), that will contain a hyperlink which opens another window on the main page?

    An example of what I'm trying to do can be found here:

    http://www.eikones.com/test/test.html

    If you open Window2, you'll see a link to open Window1. Is there a way to make this link open window1 on the main page?

    thanks,
    n.

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

    Default

    Sure, for a IFRAME based DHTML window, the way to reference anything on the main page is just to use the "parent." keyword, for example:

    Code:
    <a href="javascript:parent.openwindow1()">sdffdfd</a>
    The above link is assumed to be inside Window 2, and "openwindow1()" is a function on the main page that opens Window 1.

  3. #3
    Join Date
    Nov 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi again,

    I'm not very familliar with javascript, so I think I need some more help.

    I tried using the code above, but IE gives me an "object doesn't support this property or method" error when the link is clicked. Doesn't seem to work in firefox either.

    You can see my test pages on: http://www.eikones.com/test/test.html

    Basically, on the main window, the code that opens window1 is:

    <a href="#" onClick="ajaxwin=dhtmlwindow.open('window1', 'iframe', 'window1.html', 'window1', 'width=650px,height=200px,left=300px,top=100px,center=1,resize=0,scrolling=1'); return false">open window 1</a>

    So what I need to do it to put a link in the external page that loads in the iframe of window2 (i.e. window2.html), that will trigger the same action on the main page.

    Please note that, on the main page, window1 does not show up using a function. There will be too much data in there, so we only want it to show up when the user wants (so there is just javascript code in the hyperlink of the main page, no javascript functions).

    thanks,
    n.

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

    Default

    First, make sure on your main page, that the variable you assign each DHTML window is unique:

    Code:
    <a href="#" onClick="ajaxwin=dhtmlwindow.open('window1', 'iframe', 'window1.html', 'window1', 'width=650px,height=200px,left=300px,top=100px,center=1,resize=0,scrolling=1'); return false">open window 1</a>
    
    <br /><br />
    
    <a href="#" onClick="ajaxwin2=dhtmlwindow.open('window2', 'iframe', 'window2.html', 'window2', 'width=250px,height=400px,left=300px,top=100px,center=1,resize=0,scrolling=1'); return false">open window 2</a>
    I've given the second window a "ajaxwin2" name to make it unique. Secondly, to make it easier to call window1 from window 2, encase the code for window1 in a function instead, so you end up on your main page with this instead:

    Code:
    <script type="text/javascript">
    
    function openwindow1(){
    ajaxwin=dhtmlwindow.open('window1', 'iframe', 'window1.html', 'window1', 'width=650px,height=200px,left=300px,top=100px,center=1,resize=0,scrolling=1')
    }
    
    </script>
    
    <a href="#" onClick="openwindow1(); return false">open window 1</a>
    
    <br /><br />
    
    <a href="#" onClick="ajaxwin=dhtmlwindow.open('window2', 'iframe', 'window2.html', 'window2', 'width=250px,height=400px,left=300px,top=100px,center=1,resize=0,scrolling=1'); return false">open window 2</a>
    Then, on the Iframe page within window2, your link to call window1 would look like:

    Code:
    <a href="javascript:parent.openwindow1()">Open window 1</a>

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
  •