473,770 Members | 6,091 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

call function in iframe

I have document with an iframe in it. I'm able to call a javascript
function in the main-document from the javascript inside the
iframe-document. I have difficulties to do the other way round, i.e. to
call a function in the iframe-document from javascript in the main-document.
TIA

Christian

Jul 20 '05 #1
5 94261

"Christian Radermacher" <ra***@inwind.i t> schreef in bericht
news:C9******** *************@n ews1.tin.it...
I have document with an iframe in it. I'm able to call a javascript
function in the main-document from the javascript inside the
iframe-document. I have difficulties to do the other way round, i.e. to
call a function in the iframe-document from javascript in the main-document.


The following works with IE, Opera 7 and Mozilla when both pages are hosted
on the same domain/environment:

d = document;
f = d.frames ? d.frames['frameName'] : d.getElementByI d('frameId');
p = f.document || f.contentWindow .document;

p.functionName( );
JW

Jul 20 '05 #2


Christian Radermacher wrote:
I have document with an iframe in it. I'm able to call a javascript
function in the main-document from the javascript inside the
iframe-document. I have difficulties to do the other way round, i.e. to
call a function in the iframe-document from javascript in the
main-document.


Use
<iframe name="iframeNam e"
and then
if (window.frames. iframeName && window.frames.i frameName.funct ionName) {
window.frames.i frameName.funct ionName();
}


--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3


Christian Radermacher wrote:
I have document with an iframe in it. I'm able to call a javascript
function in the main-document from the javascript inside the
iframe-document. I have difficulties to do the other way round, i.e. to
call a function in the iframe-document from javascript in the
main-document.


Use
<iframe name="iframeNam e"
and then
if (window.frames. iframeName && window.frames.i frameName.funct ionName) {
window.frames.i frameName.funct ionName();
}


--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #4
nec
I've got the same problem as Christian..

When i use the functioncall window.frames.c ontens.alerter( 'dsa') (in then
iFrame called contens, and the function called alerter) i get this message
in the FireFox Javascript Console:

Error: window.frames.c ontens has no properties

The script wors fine in IE (or rather: a variant of it) som the frame name
and fuction is right.

How was it solved?
Jul 23 '05 #5
Hi,

In article
<aa************ *************** ***@localhost.t alkaboutprogram ming.com>, Nec
wrote:
When i use the functioncall window.frames.c ontens.alerter( 'dsa') (in then
iFrame called contens, and the function called alerter) i get this message
in the FireFox Javascript Console:

Error: window.frames.c ontens has no properties

The script wors fine in IE (or rather: a variant of it) som the frame name
and fuction is right.


The parent page of the IFrame needs to contain the functions called by a
page loaded into the IFrame.

I hope it helps,

Ranbir
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
45523
by: Dave Hammond | last post by:
In document "A.html" I have defined a function and within the document body have included an IFRAME element who's source is document "B.html". In document "B.html" I am trying to call the function defined in "A.html", but every attempt results in an "is not a function" error. I have tried to invoke the function using parent.document.funcname(), top.document.funcname(), and various other identifying methods, but all result in the above...
9
2179
by: Paul | last post by:
HI! I need to call a function that is located in the parent. I need it so that it calls when the child page in the iframe loads. Would it be better to use an onload event in the body? if so how do I call it from the child page? -- Thanks in advance :) Paul
5
3178
by: Adrian | last post by:
Is there a way (understandably non-portable) to get the call stack from within a function? That is, assuming the application has been compiled with symbols, get the list of calling function names (similar to dbx "where" command"). I am working with IBM compiler and AIX but any other OS/compiler solution would be interesting as well. To answer the inevitable question why I want this, I am writing a simple profiler for my library....
18
43566
by: Chris Ianson | last post by:
Hi geniuses (or is that genii, or genies) The challenge is as above really. I have a page with an iframe in it, and need to call a JS function in the *parent* page, *from* inside the iframe. (It's for Google Maps, but I won't bore you with the complexities of that, as it doesn't affect the question). Mochas kudos to anyone able to solve this widdle.
2
15800
by: cont | last post by:
Hi I have the following simple page: <HTML> <TITLE>Test</TITLE> <HEAD> <script language="javascript"> function doSubmit() { alert('test'); window.frames.item(0).updateParent();
1
3870
Fuhrer
by: Fuhrer | last post by:
Hi all, i'm working on a page that contains 2 Frames, in the first Frame i have an iframe included. My problem is that i'm trying to call a javascript funtion located in the iframe from the second Frame but it does not work: in the second Frame: parent.mainFrame.datamain.hidemenu();
4
3875
by: Ty | last post by:
Hello all, I am creating a web site with Visual Stuido 2008. I am trying to use a java script file to create a busybox for login from this page http://blogs.crsw.com/mark/articles/642.aspx. I am using a master page senerio. The erro I'm getting is 'busyBox' is not a member of 'ASP.login2_aspx'
53
8416
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script language="javascript" type="text/javascript">
6
2633
by: Revathi Balakrishnan | last post by:
i am trying to disable some of the anchor tags which are linked with particular onmouseover and onmouseout events.i have written a javascript function.when i called this function on load of the document body, it is able to disable the tags.But when the body of the page has iframes, this script is unable to disable the tags with in the iframes. since "document.getelemetbytags" is not returning the anchor tags with in the iframe.so i need to put...
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8891
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.