Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Thanked 0 Times in 0 Posts

    close iframe that's in another domain


    I'm using lytebox to open an iframe, but the iframe url is in another domain that the parent window.

    i need to close the iframe when user clicks a button. I can do that with javascript : top.$lb.end();
    the $lb.end(); starts lytebox scripts in parent window which close the iframe and modify all the css stuff.
    That works when my iframe url is in the same domain. But when it's in another domain, that does'nt work.

    Can anyone tells me how to do that ? Starting the $lb.end() function of the parent window ?
    Thank you.

  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,703 Times in 2,679 Posts
    <iframe>'s which display content from different domains have security measures in place to prevent all sorts of evil consequences.

    So for security reasons JavaScript cannot access anything beyond the domain of the current page. This is known as the "same origin policy" and prevents a document or script loaded from one origin from getting or setting properties of a document from a different origin.

    So I don't think that what you want is possible.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


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