What is the jQuery / javascript context for a frame inside an iframe?

Let me preface this with ... I referenced this question / answers and it seems to contain hints, but I'm still missing the whole picture.

Run jQuery in the context of another frame

Essentially, the structure of the index page is

<html>
<body>
  <div class="frames-wrap">
      <iframe id="this-iframe" src="location.php">

      </iframe>
  </div>
</body>
</html>

location.php then contains a set of frames (oh, not my idea ...) that has two frames that are set up like this ...

<frameset cols="350,*">
  <frame src="search.php" id="frame_search" name="search"/>
  <frame src="edit.php" id="frame_edit" name="edit" />
</frameset>  

if I want to manipulate objects between the index page and these elements, how would I do it?

I constantly think that the context should be something like window.parent.frames[0].document... what else am I missing?

+5
source share
4

: iframes, .

iframe, jQuery,

element = $("#this_iframe").contents().find("#frame_search")

contents(). . Traversing/contents

+2

, technicolorenvy , , .

- :

var iframeDoc = document.getElementById('myIframe');
iframeDoc = (iframeDoc.contentWindow) ? iframeDoc.contentWindow : (iframeDoc.contentDocument.document) ? iframeDoc.contentDocument.document : iframeDoc.contentDocument;


// From the parent window
$('p', iframeDoc).html('Hello from parent');

http://docs.jquery.com/Core/jQuery#expressioncontext

+2

, JavaScript, , , window.top.this_iframe.frame_edit.document, .

+1

. , iframe DOM. , , ready(), , iframe, , $(document).ready().

!

0

All Articles