JavaScript的;从其他帧中访问框架集框架 [英] Javascript; Accessing frameset frames from within other frames

查看:81
本文介绍了JavaScript的;从其他帧中访问框架集框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用框架集的系统,在框架集框架内有一些调用,如;

I have a system in place which uses a frameset, within the frameset frames there are some calls like;

top.frame1.location = "newlocation"; 

top.frame2.afunction(); 

但是我正在更新系统,现在框架集位于iframe内部,显然所有的top.frame.whatever调用不再起作用。现在我正试图找到一个不涉及改变顶部的解决方案。在大量运行各种功能的页面中。

However I am updating the system, and now the frameset resides inside an iframe, so obviously all of the top.frame.whatever calls no longer work. Now I'm trying to find a solution which doesn't involve changing the "top." in the ton of pages that run various functions.

我在最顶层的网页上尝试过这样的事情;

I've tried in the top most page doing something like this;

frame1 = $('#containerframe').contents().find('#frame1');

但这似乎不起作用,它只是说top.frame1.document在尝试时是未定义的访问该文件。

But that doesn't seem to work, it just says top.frame1.document is undefined when trying to access the document.

任何建议都会很酷:)

推荐答案

您使用jQuery集覆盖了 top.frame1 中的值,该jQuery集与默认值(这是一个窗口对象)不是同一个对象,这就是为什么你是得到未定义错误 - jQuery集没有 文档属性。

You are overwriting the value in top.frame1 with a jQuery set, which is NOT the same object as the default (which is a window object) which is why you are getting the "undefined" error - a jQuery set doesn't have a document property.

如果你想修改这个而不用更改你对top.frame1的所有引用,那么你有几个选择。假设 #containerframe 是你的iframe,我认为这样可行

If you want to fix this without changing all your references to top.frame1, then you have a couple choices. Assuming #containerframe is your iframe, I think this will work

在你父母的页面中

frame1 = self.frames.containerframe.frames.frame1;



编辑



frames 收集 name 属性,所以请确保你的iframe看起来像这样

EDIT

The frames collection works off of name attributes, so make sure your iframe looks like this

<iframe id="containerframe" name="containerframe" />

这篇关于JavaScript的;从其他帧中访问框架集框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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