473,320 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 94222

"Christian Radermacher" <ra***@inwind.it> schreef in bericht
news:C9*********************@news1.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.getElementById('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="iframeName"
and then
if (window.frames.iframeName && window.frames.iframeName.functionName) {
window.frames.iframeName.functionName();
}


--

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="iframeName"
and then
if (window.frames.iframeName && window.frames.iframeName.functionName) {
window.frames.iframeName.functionName();
}


--

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.contens.alerter('dsa') (in then
iFrame called contens, and the function called alerter) i get this message
in the FireFox Javascript Console:

Error: window.frames.contens 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.talkab outprogramming.com>, Nec
wrote:
When i use the functioncall window.frames.contens.alerter('dsa') (in then
iFrame called contens, and the function called alerter) i get this message
in the FireFox Javascript Console:

Error: window.frames.contens 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
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...
9
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...
5
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...
18
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. ...
2
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
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...
4
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...
53
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...
6
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.