在frame之间互相调用javascript函数
来源:互联网 发布:win10更新windows.old 编辑:程序博客网 时间:2024/04/28 22:08
mixing functions and frames
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:
<BODY onLoad="parent.buildindx();">
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 <frameset> 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 <frameset> tag.
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:
<BODY onLoad="parent.buildindx();">
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 <frameset> 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 <frameset> tag.
- 在frame之间互相调用javascript函数
- 在frame之间互相调用javascript函数
- 在一个类里面 成员函数之间的互相调用
- doc 类 view类,frame类之间如何互相调用
- doc类,view类,frame类之间如何互相调用
- MFC doc类,view类,frame类之间互相调用
- doc类,view类,frame类之间如何互相调用
- MFC doc类,view类,frame类之间互相调用
- MFC doc类,view类,frame类之间互相调用
- MFC doc类,view类,frame类之间互相调用
- javaScript 框架函数互相调用
- Android API与Javascript之间互相调用
- 两个Frame之间进行调用函数
- 不同 frame 之间调用 js 函数
- 子类之间的成员函数互相调用
- 两个JS之间的函数互相调用
- JS在页面Frame和子Frame之间的调用
- doc,view,frame互相调用
- 过滤器和拦截器使用
- 一些面试题
- 深入理解:立即调用的函数表达式
- UVa 10154. Weights and Measures
- 2012-03-09
- 在frame之间互相调用javascript函数
- 导致java.lang.NullPointerException异常的一种情况
- 计算机专业技能
- 输出两个数的最小
- java JTable 中设置没列的宽度
- 二叉树的三种遍历的非递归实现
- 开始自己的opencv之旅
- 输入三个数的和及平均值
- Gentoo Linux下查看工作组网络时提示:Nautilus cannot handle "smb" locations.