JavaScript error (Opera, Netscape) - calling function from different frame

  • Thread starter Dan Tartakovsky
  • Start date
D

Dan Tartakovsky

Hi, folks.
Does this error below look familiar to you? I'm trying to access
function in one frame from the other frame. Error is received while
working with Opera or Netscape (different errors). No problems are
encountered with Microsoft IE - everything works fine. Any ideas about
direction?


// Opera error

Inline script thread
Error:
name: ReferenceError
message: Security error: attempted to read protected variable


Javascript URL thread:
"javascript:top.frames.code.menuItemSelect(13);"
Error:
name: Error
message: Security violation

// Netscape error

Error: top.frames.code.docMenu has no properties
Source File: http://localhost/web/Test/JavaScript/Menu/docs/redefineTextColor.htm
Line: 60

Thanks,
Dan Tartakovsky
 
K

kaeli

\
Error: top.frames.code.docMenu has no properties

Try using
top.frames["frameName"].document.code.docMenu

where frameName is the name given to the frame in the frameset.
I also assume code is a property of document (since you posted no code,
I have no idea what it is). If it is a property of the window object,
remove "document" from the above.
top.frames["frameName"].code.docMenu

Other than that, I'd have to see the javascript code, as well as the
html, to be able to say anything else, so I could see what objects were
what.

Sometimes it helps to get a free Geoshitties or Angelfire account and
upload relevant code (just enough to show the problem) so we can bring
it up in our browsers and see everything.
 
D

Dan Tartakovsky

Hi.
to simplify the problem: I have 2 frames - "code" and "main".

In the "code" one I've defined function myFunction:

<head>
<script>
function aa(b) {
this.LINE=b;
}
var bb = new aa(true);
</script>
</head>

In the "main" frame I do following:

<html>
<head>
<script>
function onCall() {
alert("Value is : " + top.frames.code.bb.LINE);
}
</script>
</head>
<body>
<input type="button" onClick="onCall();" value="Click" />
<body>


It works excellent in IE, but not Netscape.

Error I get in Netscape is:
-------------------------------------------
Error: top.frames.code.bb has no properties
Source File: http://localhost/web/Test/JavaScript/Menu/docs/main.htm
Line: 5
------------

And by the way, changing top.frames.code.bb.LINE to
top.frames["code"].bb.LINE or top.frames["code"].document.bb.LINE does
not help.

Any ideas?

Thanks,
Dan
 
L

Lee

Dan Tartakovsky said:
Hi.
to simplify the problem: I have 2 frames - "code" and "main".

In the "code" one I've defined function myFunction:

<head>
<script>
function aa(b) {
this.LINE=b;
}
var bb = new aa(true);
</script>
</head>

In the "main" frame I do following:

<html>
<head>
<script>
function onCall() {
alert("Value is : " + top.frames.code.bb.LINE);
}
</script>
</head>
<body>
<input type="button" onClick="onCall();" value="Click" />
<body>


It works excellent in IE, but not Netscape.

Error I get in Netscape is:
-------------------------------------------
Error: top.frames.code.bb has no properties
Source File: http://localhost/web/Test/JavaScript/Menu/docs/main.htm
Line: 5
------------

And by the way, changing top.frames.code.bb.LINE to
top.frames["code"].bb.LINE or top.frames["code"].document.bb.LINE does
not help.

Any ideas?

It works fine for me in Netscape 7, even with the typo in the
closing </body>. You've probably got a syntax error in your
frameset page that IE is forgiving, but Netscape won't allow.
 
P

PeterB

kaeli said:
Which Netscape? Including version. 7.0 is a little buggy, as is 6.0 and
some versions of 4. I don't think 4 supports the new object creation
either.
Also, is this on Mac or Win or Unix?

Tested in NN7.1 on Win, it worked fine.

--

I have exactly the same problem in Opera (7.11 - build 2887) with the classic:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="Javascript">
function blank() { return "<HTML>default text</HTML>" }
</SCRIPT>
</HEAD>

<FRAMESET ROWS="5%, *>
<FRAME NAME="f1" SRC="javascript:parent.blank()">
<FRAME NAME="f2" SRC="javascript:parent.blank()">
</FRAMESET>

</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top