• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

location of a JS in frame

 
selvakumar Thiyagarajan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am creating a page using frames. The page contains two frames namely menu.html and display.html. If i click an item in menu.html frame , there should be a response in the display.hmtl frame. JS is located in the menu.html. but now i am not getting required response.

Code: HOME.html
<html>
<head>
</head>

<frameset cols="20%, 80%">
<frame src="Menu.html" id="frame1"/>
<frame src="display.html" id="frame2" />
</frameset>

</html>


Menu.html
<html>
<head>
</head>

<body>

<a href="menu.html" id="text" onclick="call()">Text</a>
<a href="menu.html" id="button" onclick="call()">Submit</a>

<script type="text/javascript">
function call()
{
alert("hi")
var x=parent.frame1.document.getElementById("text").id
alert(x)
var y=parent.frame2.document.getElementById("text").id
alert(y)
if(x==y)
{
alert("yes! its equal")
parent.frame2.document.getElementById(button).style.display="none"
}

}
</script>


</body>
</html>


Display.html

<html>
<head></head>
<body >
<input type="text" ><input type="button" value="Click">


</body>
</html>


Also, where the JS should be located when developing a page using frames.?
Thanks in advance!!!

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the future use code tags, makes it easier to rad with correct indenting and coloring.

Eric
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not canceling the click event so the link is firing. You also have an issue that you have an undeclared variable button being referenced and your second frame has no id on your button so getElementById will fail!

Eric
 
selvakumar Thiyagarajan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
will it work now? Can you please help in killing the click or any event?

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
return false is what you are after.

Eric
 
selvakumar Thiyagarajan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric, i am not able to grasp your idea. If you dont mind, Can you please clear it once again with a code snippet?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic