Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    two questions regarding iframes

    Hi people

    I got 2 questions regarding the usage of frames:
    1) How can I calculate the exact top-left coordinate of an iframe which is located in the screen? The top-left coordinate needs to be in relation to the entire screen.
    2) Consider the following: Page A opens a modal window B using window.showModalDialog(). Page B contains an IFrame C which is used to interact with the server.
    When IFrame C reloads, I would like page B to close and page A to reload automaticaly.
    I tried the following in C's body tag:
    Code:
    <body onload="parent.opener.location.reload(true); parent.close();">
    page B gets closed with no problem but I get a JavaScript error on the first line saying: 'parent.opener.location' is null or not an object.

    I would appreciate any help in any of the questions.
    regards

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,960
    Thanks
    0
    Thanked 236 Times in 233 Posts
    You have to passed the window reference to the showModalDialog method.

    window.showModalDialog('test.htm', window)

    The dialog window now has the reference to the opener window by accessing the dialogArguments property.

    in the dialog page (Page B):
    Code:
    function reloadParent(){
       var win = window.dialogArguments;
       win.location.reload(true);
       window.close();
    }
    then in page C:
    Code:
    <body onload="parent.reloadParent();">

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As I said

    The JavaScript code that has to run is in the context of the IFRame C and not thw window B.
    thus if you write:
    Code:
    function reloadParent(){
       var win = window.dialogArguments;
       win.location.reload(true);
       window.close();
    }
    Then window refers to the C IFrame which is wrong.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,960
    Thanks
    0
    Thanked 236 Times in 233 Posts

    Have you tried the code?

    That function is in Page B so it runs in window B's context not in the calling iframe's.

  • #5
    New Coder
    Join Date
    Mar 2004
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I managed to solve it by passing 'self' in the dialogArguments.

    thanks for the help

  • #6
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exact Placement of Iframe

    <div style="position:absolute;left:70.2%;top:149;">
    <iframe src="http://www.html" name="whatever" frameborder="0" noresize width="160" height="245">
    </iframe>
    </div>

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,960
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Quote Originally Posted by davidklonski
    I managed to solve it by passing 'self' in the dialogArguments.

    thanks for the help
    window is synonymous to self, so I don't know why window didn't work for you.


  •  

    Posting Permissions

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