471,338 Members | 950 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Calling a function i Javascript (Firefox)

nec
Hi,

I'm having trouble calling a function thats located in a iFrame from the
parent. Shortly, i can't figure out the location in DOM.

In IE it works fine with a simple line of
window.contens.alerter('wassa?'), but it doesnt, of course work in Firefox
(0.8).

I've tried document.getElementById('contens').alerter('wassa? ') and
document.getElementById('contens').document.alerte r('wassa?') and so on.
Apparently i've missed the right one. What is it?

(the message in the Firefox JavaScript console is: Error:
document.getElementById("contens").document has no properties)

The iframe's name is (as above) 'contens'.
Best Regards, Anders Brohäll

Jul 23 '05 #1
4 3510
"nec" <an****@tdcnova.com> writes:
I'm having trouble calling a function thats located in a iFrame from the
parent. Shortly, i can't figure out the location in DOM.
I assume it is a global function in the document in the iframe. In that
case, it is not in the DOM (Document Object Model) at all. It is on the
window object, which is not part of the document.
In IE it works fine with a simple line of
window.contens.alerter('wassa?'), but it doesnt, of course work in Firefox
(0.8).
If it works in IE, it's probably not a cross-domain scripting problem.
I've tried document.getElementById('contens').alerter('wassa? ')
The function is not in the iframe element in the current page's DOM.
and document.getElementById('contens').document.alerte r('wassa?')
and it doesn't have a "document" property either. It has a
"contentDocument" property that refers to the document element
of the page in the iframe, but that won't give you access to the
global variables in its window object.
and so on. Apparently i've missed the right one. What is it?
Try:
window.frames['contens'].alerter('whatever');
(not checked)
(the message in the Firefox JavaScript console is: Error:
document.getElementById("contens").document has no properties)


Correct. The "document" property is undefined.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
nec
Nopes, doesn't work either.

window.frames['contens'].alerter('whatever');
Error: window.frames.contens has no properties

Any other suggestions? I've searched the web for any kind of solution,
without luck. It seems as there is a few people before me have experianced
this problem, but i cant find it solved before.

Where could i find documentation about this for Mozilla?

Jul 23 '05 #3
nec wrote:
I'm having trouble calling a function thats located in a iFrame from the
parent. Shortly, i can't figure out the location in DOM.
Let's see if I can help quickly and simply. It won't solve your problem,
but it may point out where the mistakes are so that you can try other
methods to make it work.
In IE it works fine with a simple line of
window.contens.alerter('wassa?'), but it doesnt, of course work in Firefox
(0.8).
Ok... "window.contens.alerter('wassa?')" is quite clearly coded for only
IE and compatible systems and will not work on standard ones. You know
this already, I presume.
I've tried document.getElementById('contens').alerter('wassa? ') and
document.getElementById('contens').document.alerte r('wassa?') and so on.
Apparently i've missed the right one. What is it?
The first part of your statement [document.getElementById('contens')]
will get hold of the <iframe> element. However, this is an ELEMENT and
not a document, so it only has objects that are associated with elements
and that does not include EITHER "document" OR "alerter" so neither of
your statements can work. This is, of course, why you get the error
message you report (below).
(the message in the Firefox JavaScript console is: Error:
document.getElementById("contens").document has no properties)

The iframe's name is (as above) 'contens'.

The NAME is irrelevant and should be avoided. You should use the ID
rather than the name. Better yet, refer to the ID of the "alerter" part
of your webpage to get that element specifically.
Jul 23 '05 #4
nec wrote:
Nopes, doesn't work either.
*What* doesn't work either? <http://netmeister.org/news/learn2quote.html>
window.frames['contens'].alerter('whatever');
Error: window.frames.contens has no properties
Is the frame named "contens"? What exactly is "alerter"?
Post *real* code (of post an URI if it's too much), not example code.
Where could i find documentation about this for Mozilla?


AFAIS it is not a Mozilla problem, it is a DOM
problem that occurs in every UA but IE.
PointedEars
--
When the computer learns to speak natural English, all errors will
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by JS | last post: by
18 posts views Thread by dhtml | last post: by
reply views Thread by rosydwin | last post: by

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.