473,685 Members | 3,197 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 94254

"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
45504
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
2170
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
3172
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
43548
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
15795
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
3857
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
3862
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
8384
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
2631
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
8569
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
8504
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
9043
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
8758
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
7584
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...
1
6431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.