| Author |
location of a JS in frame
|
selvakumar Thiyagarajan
Greenhorn
Joined: Oct 06, 2008
Posts: 28
|
|
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
Joined: Nov 08, 2001
Posts: 15357
|
|
In the future use code tags, makes it easier to rad with correct indenting and coloring.
Eric
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
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
Joined: Oct 06, 2008
Posts: 28
|
|
Eric,
will it work now? Can you please help in killing the click or any event?
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
return false is what you are after.
Eric
|
 |
selvakumar Thiyagarajan
Greenhorn
Joined: Oct 06, 2008
Posts: 28
|
|
|
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
Joined: Nov 08, 2001
Posts: 15357
|
|
http://www.quirksmode.org/js/events_early.html
Eric
|
 |
 |
|
|
subject: location of a JS in frame
|
|
|