brite, a MVC Framework for jQuery

jQuery: iFrame find elements

July 20th, 2009 by jeremychone
$(’#iframeID’).contents().find(’#someID’).html();

Source: http://simple.procoding.net/2008/03/21/how-to-access-iframe-in-jquery/

4 Responses to “jQuery: iFrame find elements”

  1. Praveen Says:

    Nice post on how to access content in IFrame in Jquery here.
    http://praveenbattula.blogspot.com/2009/09/access-iframe-content-using-jquery.html

  2. videolar Says:

    how can i access the value inside iframe help me please

  3. jeremychone Says:

    @videolar If the iFrame is from the same server, then the above solution should work. Otherwise, you are kind of doomed.

  4. charly Says:

    the ONLY dependency whether you can access the content of an iframe or not, is the same origin policy.

    Whenever the content of the parent and (i)frame is loaded from a host with the same hostname then you are OK, if you have the ability to set the document.domain property in the documents loaded.

    Caveat: they have to be set in BOTH documents, i.e. NOT only the iframe content.

    Then you can easily access content on http://www.example.com from whatever.example.com and vice versa.

    (in this example you’d have to set:

    document.domain = “example.com”;

    in BOTH, the accessing and the accessed document)

Leave a Reply