Jump to content

Controling contents on other frames with java


Guest rycfung

Recommended Posts

Guest rycfung

Hi,I'm trying to change the content of one frame from another using javascript. I've read some example online and they seem to work by using the parent or top attribute. However, I got the error "top.frame has no properties" in my firefox javascript console. How come?Here's my code:INDEX.XHTML<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Calendar </title> </head> <body> <frameset cols="25%, 75%"> <frame name="inter" src="interface.xhtml"/> <frame name="calendar" src="calendar.xhtml"/> </frameset> </body></html>INTERFACE.XHTML<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Interface </title> <script language="JavaScript" type="text/javascript"> </script> </head> <body> <h1> Interface </h1> </body></html>CALENDAR.XHTML<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Calendar </title> <script language="JavaScript" type="text/javascript"> function test() { //str=top.inter.toString(); top.frame[0].document.getElementsByName("h1")[0].innerHTML="interface.xhtml"; } </script> </head> <body onload="test();"> <h1> Calendar </h1> </body></html>

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...