www.webdeveloper.com
Results 1 to 5 of 5

Thread: [RESOLVED] Close a Iframe from inside the iframe

Hybrid View

  1. #1
    Join Date
    Sep 2011
    Posts
    3

    resolved [RESOLVED] Close a Iframe from inside the iframe

    Hallo:

    I'm using dhtmlmodal for creating modal windows.
    Modal window is created inside a "iframe".
    My problem:
    I open a modal window, that window is redirected to another page in a different server and I try to close the window with javascript.
    But dhtml modal closes the window with:
    parent.vmodal.hide()
    Due to the window in the iframe is from a different host, it say "permission denied".
    Also windows.close() doesn't work with a iframe.
    My question:
    How can I close an iframe from inside the iframe?

    Thanks

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by FelipeGar View Post
    I open a modal window, that window is redirected to another page in a different server and I try to close the window with javascript.
    No way. For obvious security reasons, it is not possible such JavaScript relationship between documents belonging to different domains.

  3. #3
    Join Date
    Sep 2011
    Posts
    3
    Then you mean

    - If the document is from a different domain. There is no way to close this iframe form the document inside the iframe? This shouldn’t be a problem of security, no? if possible, how can I do it?

    - From the main window, is possible to read a field of the iframe (in a different domain). Suppose no, right? If possible, i can use a timer for searching a filed in the iframe and close the window. But don't know how to read a filed in the frame from the main window.

    Thanks

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by FelipeGar View Post
    Then you mean

    - If the document is from a different domain. There is no way to close this iframe form the document inside the iframe? This shouldn’t be a problem of security, no? if possible, how can I do it?
    Once again: it is not possible. Full stop.
    Quote Originally Posted by FelipeGar View Post
    - From the main window, is possible to read a field of the iframe (in a different domain). Suppose no, right?
    That is possible. But only with a help of a server-side proxy application.
    Quote Originally Posted by FelipeGar View Post
    If possible, i can use a timer for searching a filed in the iframe and close the window.
    No. Reading a file is one thing. Closing a window is another thing.

    Let me tell you why it is not possible. If both documents (the parent document and "iframed" document) belong to the same domain, there is a reciprocal javascript reference between them. If they belong to different domains, there is no javascript relationship between them, so that there is no reference to which you can command: "you there! close yourself!". If no reference, no action is possible.

  5. #5
    Join Date
    Sep 2011
    Posts
    3
    Understood.

    Thank you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles