`
zgqynx
  • 浏览: 1355826 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

在 frame 之间 调用函数

阅读更多
原文
http://sharkysoft.com/tutorials/jsa/content/038.html

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.

Charlton Rose
April 25, 1997
分享到:
评论

相关推荐

    C# 获取调用函数 参数名称和值

    在C#编程中,获取调用函数的参数名称和值是一项常见的需求,特别是在日志记录、调试或动态处理参数时。下面将详细讲解如何在C#中实现这一功能。 首先,我们要了解C#中的反射机制。反射是.NET框架提供的一种强大工具...

    函数之间调用同一个对象方法

    在探讨“函数之间调用同一个对象方法”的主题时,我们首先需要理解几个核心概念:函数、对象、方法以及事件监听器。这些概念是现代编程语言,尤其是面向对象编程语言中的基石,它们共同构建了复杂软件系统的逻辑框架...

    二进制讲解函数调用

    在调用函数时,我们需要知道函数的入口地址,以便CPU能正确地跳转到函数的起始位置执行。 2. **参数传递**:函数调用时可能需要传递参数,这些参数可以放在寄存器或者栈中。在x86架构下,通常先使用EAX, EBX, ECX, ...

    函数调用过程种种细节分析

    2. 返回地址保存:调用函数前,当前指令的地址(即调用函数后的下一条指令)被保存到堆栈帧中,以便在函数返回时恢复。 3. 堆栈帧创建:为新函数分配空间,存储局部变量和其他必要信息。 4. 控制转移:执行流从调用...

    frame与frame之间如何用JavaScript传值

    本文将详细讲解如何使用JavaScript在frame与frame之间进行值的传递。 首先,了解基本概念。`window`对象是浏览器的全局对象,它提供了对浏览器窗口的各种控制,包括访问框架。`frames`属性是`window`对象的一个成员...

    追踪谁调用了函数

    每次函数调用都会在堆栈上创建一个新的帧(Frame),存储返回地址和局部变量等信息。通过遍历这个堆栈,我们可以逆序地查看函数调用的顺序,从而得知哪些函数调用了目标函数。 在C++中,实现堆栈追踪通常有两种方法...

    qt 调用javascript函数 带参数

    本篇文章将深入探讨如何在Qt中调用JavaScript函数并传递参数,以实现更丰富的功能。 首先,Qt的Webkit模块是实现这一目标的关键。Qt Webkit是一个基于WebKit引擎的组件,它允许Qt应用渲染网页内容,并与网页进行...

    用js互相调用iframe页面内的js函数

    在这个场景下,涉及到的一个常见需求就是如何用JavaScript在主页面与`iframe`页面之间互相调用函数,以便于进行更复杂的交互。 标题提到的问题是在各种浏览器中,尤其是考虑到跨浏览器兼容性时,如何用JS实现主页面...

    WPF 实现导航通过Frame的Navigate函数实现导航

    本示例着重讲解如何利用`Frame`控件的`Navigate`函数来实现页面间的导航,并且通过设置`NavigationUIVisibility`属性隐藏导航UI,使得界面更加简洁,更适合初学者学习。 首先,我们需要了解`Frame`控件。`Frame`是...

    iframe子父页面调用js函数示例.docx

    "iframe子父页面调用js函数示例" 在实际项目中,iframe 子父页面调用 js 函数是非常有用的。下面是一个示例,演示如何在 iframe ...6. JS 实现 iframe 跨页面调用函数的方法 7. JS 如何对 Iframe 内外页面进行操作总结

    函数调用机制C与汇编相互调用[整理].pdf

    当函数A调用函数B时,B的栈帧会建立在A的栈帧下方,A的返回地址被压入栈中,以便B返回后能正确返回到A的下一条指令。 函数调用和返回主要由CALL和RET指令完成。CALL指令将返回地址压栈并跳转到被调用函数,RET指令...

    短时能量计算程序

    在pr2_3_1程序中调用了frame2time函数,用于计算分帧后每一帧对应时间。 名称:frame2time 功能:计算分帧后每一帧对应的时间。 调用格式:frameTime=frame2time(frameNum,framelen,inc,fs)

    jsp页面不同frame间调用

    例如,`iframe`中的`jsp`页面可以调用父页面的JavaScript函数: ```jsp ;charset=UTF-8" language="java" %&gt; &lt;title&gt;iframe内的页面 function sendDataToParent(data) { window.parent.postMessage(data, "*...

    js实现iframe跨页面调用函数的方法

    在JavaScript中,实现iframe跨页面调用函数是一个常见的需求,特别是在构建复杂的Web应用程序时。当一个页面(父页面)嵌入了另一个页面(子页面)作为iframe时,有时需要在两个页面之间通信,调用各自的功能。下面...

    同级iframe间的函数调用

    标题“同级iframe间的函数调用”涉及的是如何在不同`iframe`之间共享数据和交互,这是跨域安全策略下实现页面间通信的一种方式。 在同一个域名下,`iframe`可以相互访问,这是因为它们被视为同一源(same-origin ...

    JavaScript调用window函数.docx

    window 对象的 self 属性包含当前窗口的标志,利用这个属性,可以保证在多个窗口被打开的情况下,正确调用当前窗口内的函数或属性而不会发生混乱。 9. name 属性 window 对象的 name 属性返回窗口名称,这个名称是...

    函数调用中堆栈的个人理解共4页.pdf.zip

    - **压栈**:在进入函数之前,系统会在堆栈上保存当前的上下文,包括返回地址(调用函数后的下一条指令)、局部变量和参数。这个过程称为“压栈”。 - **执行**:函数体内的代码开始执行,可以访问其自己的局部...

    C语言函数调用栈(一) - clover_toeic - 博客园1

    在C语言中,每个函数调用都会在内存中创建一个新的栈帧(stack frame),该栈帧用于存储函数的局部变量、参数和返回地址等信息。栈帧的结构通常包括以下几个部分: * 函数的返回地址:存储函数的返回地址,以便在...

    C函数调用过程原理及函数栈帧分析 - 编程之道 - SegmentFault 思否1

    函数调用者(caller)和被调用者(callee)之间需要通过栈来传递信息,包括返回地址、参数位置以及确保函数返回后的寄存器状态恢复。 函数调用的具体过程可以分为以下几步: 1. 调用者首先将参数按照从右到左的...

    JavaScript函数调用堆栈loader

    在JavaScript中,每当一个函数被调用,一个新的调用帧(call frame)就会被添加到调用堆栈上,包含了这个函数执行的所有必要信息,如局部变量、参数等。当函数执行完毕,其对应的调用帧会从堆栈中移除,这一过程称为...

Global site tag (gtag.js) - Google Analytics