473,395 Members | 1,869 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,395 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 3601
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: JS | last post by:
I have made a function createFirstMenu where I call "resetMenu" in a JavaScript. But nothing happens when I call resetMenu. function createFirstMenu(sel){ sel = document.getElementById('sel1');...
1
by: bbammes | last post by:
I'm writing a click tracking program which calls a remote PHP script when a user clicks a link. My javascript is: <script type="text/javascript"> //<! ); ?>&clientaddress=<?php echo urlencode(...
6
by: davidiwharper | last post by:
Hi there. I'm putting together a page to collect some information from our website users and send the administrator an email. To this end I have some Javascript form validation in an external...
1
by: Memphis Steve | last post by:
Is it possible to combine multiple javascipts into one file and then call that file from a linked URL in the head section of an XHTML file? Here are the two scripts I want to use with the...
22
by: Archanak | last post by:
Hi, I am using 2-level CSS Drop Down Menu in my perl/CGI program. here is the code. #!c:/perl/bin/perl.exe use CGI qw(:standard);
15
by: Sampat | last post by:
Hi, I wanted to know the performance of calling a function pointer v/s a normal function call in javascript in a scenario where there are multiple calls in the js to the same function. Please...
4
by: r_ahimsa_m | last post by:
Hello, I am learning WWW technologies in Linux. I created index.html file which I can browse with Firefox/Konqueror using URL localhost/~robert/rozgloszenia/index.html. The page looks fine but...
18
by: dhtml | last post by:
Array.splice({}) What should it do? I think it should return a new Array with length 0. Array.splice(arr, start, deleteCount ]]) http://bclary.com/2004/11/07/#a-15.4.4.12 Example:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.