|
Q380 How do I find if a particular frame exists before attempting to use a function inside that frame?
irt.org | Knowledge Base | JavaScript | Frame | Q380 [ previous next ]
Q380 How do I find if a particular frame exists before attempting to use a function inside that frame?
Try:
<frameset rows="50%,*">
<frame src="aFrame.htm" name="aFrame">
<frame src="bFrame.htm" name="bFrame">
</frameset>
|
In aFrame.htm:
<script language="JavaScript"><!--
function someFunction() { alert('Hello World') }
//--></script>
|
In bFrame.htm:
<script language="JavaScript"><!--
function find(what) {
for (var i=0;i<parent.frames.length;i++) {
if (parent.frames[i].name == what)
return true;
}
return false;
}
//--></script>
<form>
<input type="button" value="Test" onClick="if (find('aFrame')) parent.aFrame.someFunction()">
</form>
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.