Forum Moderators: open
Files:
1 - Standard Frameset with 2 frames, "controller" and "proxy".
2 - File used for FrameA; "controller" contains a div id="navigation" with a visible style. And two methods; to show and hide the div.
3 - Numerous files used for FrameB; "proxy". Each file contains the same JavaScript code, which is slightly manipulated by an outside "dynamic page" generator (ASP/PHP/JSP). This code is used to call either one or the other of the two methods in frame 1.
How it works:
We come to the frameset and it loads FrameA into "controller" and FrameB into "proxy". FrameB's code is run to call the method in FrameA. Sometimes it works, other times the code in FrameB dies at the point it calls FrameA's method remotely. FrameB navigates to other pages that have the same JavaScript that FrameB has. These other pages either work or sporadically die as well.
Help is much appreciated. Code follows:
[bold]Frameset[/bold]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html lang="en">
<head>
<base href="http://****.yyy.com/site/frameset.jsp">
<title>The Frameset</title>
<meta http-equiv="Content-Type" content="text/html; UTF-8"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="keywords" content=""/>
<meta http-equiv="description" content=""/>
<link href="css/xxx.css" rel="stylesheet" type="text/css"/>
<link href="css/yyy.css" rel="stylesheet" type="text/css"/>
<script language="JavaScript" src="js/zzz.js" type="text/javascript"></script>
</head>
<frameset rows="54, *" border="0">
<frame src="/site/frameA.jsp" name="controller" noresize="noresize" scrolling="no">
<frame src="/site/frameB.jsp" name="proxy">
</frameset>
</html>
[bold]FrameA "controller"[/bold]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<base href="http://xxx.yyy.com/site/frameset.jsp">
<title>FrameA</title>
<meta http-equiv="Content-Type" content="text/html; UTF-8"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="keywords" content=""/>
<meta http-equiv="description" content=""/>
<link href="css/qqq.css" rel="stylesheet" type="text/css"/>
<script language="JavaScript" src="js/zzz.js" type="text/javascript"></script>
</head>
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" stats="1"><!--BEGINNING OF DEEPMETRIX STATSCRIPT-->
<script language="javascript">
// SNIP IRRELEVANT DEEPMETRIX STATSCRIPT
</script>
<!--END OF DEEPMETRIX STATSCRIPT-->
<table width="100%" height="44" border="0" cellpadding="0" cellspacing="0" class="HeaderBackground">
<tr>
<td align="right">
<div id="navbuttons" style="display:block;visibility:visible">
<table height="44" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="31" valign="middle"><a href="/site/home.jsp" target="proxy">Home</a></td>
<td width="31" valign="middle"><a href="/site/cart.jsp" target="proxy">Cart</a></td>
<td width="31" valign="middle"><a href="/site/track.jsp" target="proxy">Track</a></td>
<td width="31" valign="middle"><a href="/site/help.jsp" target="proxy">Help</a></td>
</tr>
</table>
</div>
</td>
<script language="javascript">
<!--
function hideNav() {
window.status="hide1";
var element = document.getElementById('navbuttons');
window.status="hide2";
element.style.display="none";
window.status="hide3";
element.style.visibility="hidden";
window.status="hide4";
}
function showNav() {
window.status="show1";
var element = document.getElementById('navbuttons');
window.status="show2";
element.style.display="block";
window.status="show3";
element.style.visibility="visible";
window.status="show4";
}
// -->
</script>
</tr>
</table></body>
</html>
[bold]FrameB "proxy"[/bold]
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<base href="http://xxx.yyy.com/site/frameset.jsp">
<title>FrameB</title>
<meta http-equiv="Content-Type" content="text/html; UTF-8"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="keywords" content=""/>
<meta http-equiv="description" content=""/>
<link href="css/xxx.css" rel="stylesheet" type="text/css"/>
<link href="css/yyy.css" rel="stylesheet" type="text/css"/>
<script language="JavaScript" src="js/zzz.js" type="text/javascript"></script>
</head>
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" stats="1"><!--BEGINNING OF DEEPMETRIX STATSCRIPT-->
<script language="javascript">
// SNIP IRRELEVANT DEEPMETRIX STATSCRIPT
</script>
<!--END OF DEEPMETRIX STATSCRIPT-->
<!--BEGIN: Frame Communication JavaScript-->
<script language="javascript">
<!--
function mallNavHandler() {
document.write("SECTION 1<br/>");
if (parent!= self && parent.frame['controller']!= null) {
document.write("SECTION 2<br/>");
if ('${dynamically set variable}' == 'none') {
document.write("SECTION 3 - hiding<br/>");
parent.frame['controller'].hideNav();
} else {
document.write("SECTION 4 - showing<br/>");
parent.frame['controller'].showNav();
}
document.write("SECTION 5 - it sporadically prints this. Help!<br/>");
}
document.write("SECTION 6<br/>");
}
// -->
</script><!--END: Frame Communication JavaScript-->IRRELEVANT BODY TEXT OF THIS HTML FILE.
</body>
</html>
Having that many instances of even basic script initializations could cause unusual or sporadic errors.
(Just a note: you do realize that your script will only function in Internet Explorer, right?)
Occasionally the FrameB pages will run on their own, without the overriding frameset.
> Having that many instances of even basic script
> initializations could cause unusual or
> sporadic errors.
The only thing done in the master JS is the creation of functions; no variables are declared.
> (Just a note: you do realize that your script
> will only function in Internet Explorer, right?)
What would I have to do to make it work in Mozilla or Opera? I tried it (or possibly an earlier iteration of the above script, but I did try it) in Mozilla and it also worked (sporadically, again) there.
<!--BEGIN: Frame Communication JavaScript-->
<script language="javascript">
<!--
function mallNavHandler() {
document.write("SECTION 1<br/>");
if (top!= self && top.controller!= null) {
document.write("SECTION 2<br/>");
if ('${dynamically set variable}' == 'none') {
document.write("SECTION 3 - hiding<br/>");
top.controller.hideNav();
} else {
document.write("SECTION 4 - showing<br/>");
top.controller.showNav();
}
document.write("SECTION 5 - it sporadically prints this. Help!<br/>");
}
document.write("SECTION 6<br/>");
}
// -->
</script>
But it is still sporadic, at best.
It's true that Mozilla has included handling of many IE-specific DOM elements, in order to provide a better experience for the user who surfs in a non-cross-browser web environment.
parent.frame['controller'].hideNav();
is an example of the use of IE-specific DOM elements. The "frame" array is IE-specific.
The following example meets the W3C specification, using the "frames" array:
parent.frames['controller'].hideNav();
Good all the way back to Navigator 2.0.