Jump to content

Why my frame does not work on Safari 3.0.4?


joecool2005

Recommended Posts

Hi,I want to build a simple frame.The following code works fine on IE6 and IE7 but doesn't work on Safari 3.0.4.It showed me this error message on Safari 3.0.4.

"TypeError: Value undefined (result of expression top.frames["toolbar"].doSomething2) is not object."
Why?Plz helpThxJoedefault.htm
<frameset id="frameset1" rows="119,*" name="frameset1" border="0" frameSpacing="0" frameBorder="no">		<frame name="toolbar" id="toolbar" src="button.htm" marginheight="0" marginwidth="0" scrolling="no" NORESIZE>		<frame name="top_main" id="top_main" src="button2.htm" marginheight="0" marginwidth="0" NORESIZE>	</frameset>

button.htm

<html><head><script language="JavaScript">function doSomething2(){  alert("this is my document");}</script></head><body>my page</body></html>

button2.htm

<HTML><script language="JavaScript">try{top.frames["toolbar"].doSomething2()}catch(e){alert(e);}</script><body>button2<br /></body></HTML>

Link to comment
Share on other sites

A couple guesses I'm not sure about. Bear in mind that Safari 3 is pretty new and may have a stricter attitude about stuff.1. Try parent.frames instead of top.frames2. Try calling doSomething2 from a function triggered by a button. As it is, you're caling it inline as the script in button2.htm loads. It's possible the function in button.htm hasn't finished loading yet. Despite the order in which the frames are indicated in your source, you really can't make assumptions about what finishes loading first.3. I doubt this is causing any problem, but be aware that <language="JavaScript"> is deprecated now. Use <type="text/javascript">

Link to comment
Share on other sites

FWIW, the original works in Firefox 2.0.0.11 for Mac. Not one error.That error code you quoted--was it from the alert or the error console? Have you checked the error console? So often it's the early error you don't see that triggers the error you do see.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...