|
Q1758 How do I know which frame has the focus?
irt.org | Knowledge Base | JavaScript | Frame | Q1758 [ previous next ]
Q1758 How do I know which frame has the focus?
Add a hidden variable on the frameset page, which updates when onFocus on the frame changes.
You can then access this variable from the frames using window.parent.document. The frameset:
<form name=framesetForm>
<input type=hidden id=activeFrame name=activeFrame value=1>
</form>
<frameset rows="200,*">
<frame onfocus="framesetForm.activeFrame.value = 1" name="Frame1" src="Frame1.htm">
<frame onfocus="framesetForm.activeFrame.value = 2" name="Frame2" src="Frame2.htm">
</frameset>
|
Inside the frames:
function CheckFrames() {
var activeFrame;
activeFrame = window.parent.document.framesetForm.activeFrame.value;
if (activeFrame = 1) {
alert('Frame 1 is active');
} else {
alert('Frame 2 is active');
}
}
|
Submitted by Simon Renström
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.