在frame之间互相调用javascript函数
2009-06-12 00:50
351 查看
该篇文章是我于2009年6月10日通过自己编写的工具,批量从位于在博客园的博客站点(http://chenxizhang.cnblogs.com)同步而来。文章中的图片地址仍然是链接到博客园的。特此说明!陈希章原文地址:http://www.cnblogs.com/chenxizhang/archive/2009/05/24/1488214.html原文标题:在frame之间互相调用javascript函数 原文发表:2009/5/24 4:55:00 |
I have three files, a "parent frame" file and the two files which are loaded into the frames set up by the parent. Also in the parent frame I have a javascript function defined.
In one of the frames, I need to call that function in the parent frame. I have it set up like so:
In MS Internet Explorer it works great. It does just what I want it to. However, in Netscape 3.01, it gives me an error saying "window.buildindx not a function".
It seems as though, in Explorer, it allows it to be called using the parent (window) object, but in Netscape it doesn't recognize it.
I may be doing something wrong, but I would appreciate any advice you could give me.
-- John
When a JavaScript function is defined in a document, the function becomes a method of the window or frame object in which it is defined. In JavaScript, windows and frames are treated similarly, and for the purposes of this article I will use the term "frame" to indicate either "frame" or "window."
In order for one frame to call a function defined in another frame, the caller must have a reference to the frame object containing the function. In most cases, this is just
parent . frame_name
In a two-framed document containing frames named "left" and "right," for example, the left frame can call the right frame's functions through the expression
parent . right . function_name (parameters)
Similarly, to call a function defined in the parent, or frameset document, all you need is a reference to the parent. Thus, the expression
parent . function_name (parameters)
is sufficient to call the parent frame's functions.
It appears that this is exactly what you were trying to do -- that is, to call a parent frame's function from within a child frame. Based on what you have told me, it also appears that your code is correct. So why, do you suppose, does it work in Internet Explorer but not in Netscape Navigator?
I did some research for you and came up with a startling conclusion. The current release of Netscape completely ignores JavaScript that is placed after the opening tag of a frameset document. This means that if you want to call a function defined in a frameset document, the function definition should occur before the first tag.
作者:陈希章 出处:http://blog.csdn.net/chen_xizhang 本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |
相关文章推荐
- 在frame之间互相调用javascript函数
- 在frame之间互相调用javascript函数
- MFC doc类,view类,frame类之间互相调用
- MFC doc类,view类,frame类之间互相调用
- MFC doc类,view类,frame类之间互相调用 作者:Fansy2000 (顶顶)
- MFC doc类,view类,frame类之间互相调用
- 【原创】iframe与父页面之间,变量、方法互相调用
- iOS app之间互相调用
- C和C++之间库的互相调用
- js中 frame的主窗口和子窗口之间的传值和方法调用
- 同一个C语言工程不同C文件之间的函数互相调用问题(二)
- 如何实现IE中JS和VC之间的互相调用
- vc和delphi之间动态链接库互相调用_delphi教程
- java和js之间互相调用实践(一)
- Android Ndk中C与JAVA之间的互相调用
- doc,view,frame互相调用
- 在一个类里面 成员函数之间的互相调用
- Objective C 和 Javascript 之间的互相调用
- Android 平台C# 与C++之间的互相调用方法
- doc类,view类,frame类之间如何互相调用