Jump to content

frames on safari 3 does not work


joecool2005

Recommended Posts

Hi,I have a frame that works on IE 7 but does not work on safari 3.It shows the message like this:TypeError: Value undefined (result of expression top.frames["toolbar"].doSomething2) is not object.Here is the codedefault.htm

<HTML><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></HTML>

button.htm

<html><head><script>function doSomething2(){			document.write("this is my document");}</script></head><body>my page</body></html>

button2.htm

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

Link to comment
Share on other sites

:)Sorry, I've missed something.. That's the name 'toolbar' of the frame is a reserved word..You should change it. For example, 'tool_bar'.And please remember that if you execute the script 'doSomething2()', the page may be redirected to another page. So the browser is unable to execute the script again.So I think it is better to create a <span> and use 'innerHTML' to change to text.For example, use the following code for the 'button.htm':

<html><head><script>function doSomething2(){document.all.maintext.innerHTML="this is my document";}</script></head><body><span id="maintext"></span></body></html>

And, you know, when the button2.htm is executed, the function 'doSomething2' will also be executed at once. So I think you should add a button to the page 'button.html':<input type="button" value="Click me!" onclick="java script:functionname()">create a JavaScript function:function functionname(){try{parent.tool_bar.doSomething2()}catch(e){alert(e);}} or directly link to the button.htm like this:<input type="button" value="Click me!" onclick="java script:parent.tool_bar.doSomething2()">Also, I think it is better to use:<script language="JavaScript">instead of<script>I hope it is work for your web page and my code is useful to you! :)(Am I talking too much?)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...