iframe中框架的jQuery / javascript上下文是什么? [英] what is the jQuery / javascript context of a frame within an iframe?

查看:105
本文介绍了iframe中框架的jQuery / javascript上下文是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我先说明这一点......我引用了这个问题/答案,它似乎包含线索,但我仍然缺少整个图片

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

< a href =https://stackoverflow.com/questions/539504/run-jquery-in-the-context-of-another-frame>在另一帧的上下文中运行JQuery

基本上,索引页面的结构是这个

Essentially, the structure of the index page is this

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

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

location.php然后包含一个框架集(咳咳,不是我的想法......),它有两个框架设置如此......

location.php then contains a frameset (ahem, not my idea...) that has two frames that are set up like so...

<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 go about this?

我一直认为上下文应该类似于 window.parent.frames [0] .document ...我还缺少什么?

I keep thinking the context should be something similar to window.parent.frames[0].document... what else am i missing?

推荐答案

前言:除非来自同一个域,否则您将无法访问iframe内容。

Preface: You wont be able to access the iframes contents unless it originates from the same domain.

要选择iframe中的元素,你可以使用像这样的jQuery调用

To select elements in your iframe you could use a jQuery call like this

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

关键是使用 contents()函数。请参阅遍历/内容

The key is to use the contents() function. See Traversing/contents

这篇关于iframe中框架的jQuery / javascript上下文是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆