Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes location of a JS in frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "location of a JS in frame" Watch "location of a JS in frame" New topic
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: 15376
    
    6
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: 15376
    
    6
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: 15376
    
    6
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: 15376
    
    6
http://www.quirksmode.org/js/events_early.html

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: location of a JS in frame
 
Similar Threads
Will it work now
Having trouble with a javascript assignment
struts-2 (set values to action class)
Calling outside JSP code without waiting for its response.
How to change input font and open new page in frame