how to share a variable between 3 html pages
Hi All,
I am new to html programming. I am having problem in sharing a variable between 3 html pages. I tried googling for the solution but couldn't get the right one.
A brief about my problem is...
1. I have 3 html pages, 1.htm, 2.htm & 3.htm
2. I have a variable var1 in 1.htm which is set to 0.
3. 1.htm will open 2.htm and 3.htm
4. 3.htm will update the var1 variable declared in 1.htm to 1 on onunload event.
5. 2.htm will check the status of var1 for value 1, if yes it will navigate to next page.
I have pasted the code below for 1.htm, 2.htm & 3.htm respectively.
Can anyone please help me in this regard.
Thanks in advance.
Regards,
tux09.
----------------------------------------------------------------
1.htm
--------
<html>
<head>
<title>main</title>
<script type="text/javascript">
var checkPopUpClosed = 0;
function delayed_redirect(){
window.open('3.htm','SaveAs','height=250,width=640 ,resizable=0,directions=0,location=0,toolbar=0,men ubar=0,scrollbars=0');
}
</script>
</head>
<body ><!-- masthead -->
<table border="0" cellpadding="0" cellspacing="0" summary=".">
<tr><td ><h1>Main</h1></td></tr>
</table>
<FORM method="post" name="mainForm" ACTION="2.htm">
<table cellspacing="0" cellpadding="0" border="0" summary="." >
<tr>
<td class="rightContentPane">
<br><br>
<div class="pad10">
<div>
<INPUT type="submit" name="Back" accesskey="b" alt="Back" VALUE="< Back">
<INPUT type="submit" name="Finish" accesskey="s" alt="Save As" onclick="javascript:delayed_redirect();" VALUE="Save As">
<INPUT type="submit" name="Cancel" accesskey="c" alt="Cancel" VALUE="Cancel">
</div>
</td>
</tr>
</table>
<div>
<INPUT type="hidden" name="Hide" VALUE="18489">
<INPUT type="hidden" name="shVariable" VALUE="0">
</div>
</FORM>
</div>
</body>
</html>
----------------------------------------------------------------------------------------
2.htm
--------
<html>
<head>
<title>second</title>
<meta http-equiv="refresh" content="5;" />
<script type="text/javascript">
//if (1 == document.mainForm.checkPopUpClosed.value)
var temp = 0;
if (1 == top.mainForm.checkPopUpClosed)
alert("Close received = ");//+document.mainForm.checkPopUpClosed.value);
function checkClick() {
//temp = top.parent.item.forms("mainForm","checkPopUpClosed ");
//temp = parseInt(parent.checkPopUpClosed);//.document.frames.item("shVariable");
//temp = document.getElementById("mainForm");
//temp.parentElement(shVariable);
//temp = document.mainForm.checkPopUpClosed.value;
alert("temp = "+temp);
}
</script>
</head>
<body onclick="checkClick();"><!-- masthead -->
<tr><td ><h1>Second</h1></td></tr>
<FORM method="post" name="secondForm" >
<table cellspacing="0" cellpadding="0" border="0" summary="." >
<tr>
<td >
<div >
<table width="200" border="3" cellspacing="0" cellpadding="0" summary=".">
<tr>
<td style="text-align:center;">
<br/>
<h3>Result</h3>
<br/>
In progress.
<br/><br/><br/>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</FORM>
</div>
</body>
</html>
-------------------------------------------------------------------------------
3.htm
--------
<html>
<head>
<title>third</title>
<script type="text/javascript">
function doClose(){
if (window.opener && !window.opener.closed) {
window.opener.location.href="1.htm";
}
}
function delayed_close() {
setTimeout("window.close();",7000);
}
function delayed_Openclose() {
delayed_close();
setTimeout ("doClose();", 6900);
}
function doAbnormal_Close() {
var temp2 = 0;// = document.getElementById("mainForm");
top.mainForm.checkPopUpClosed = 1;
temp2 = top.mainForm.checkPopUpClosed;
//temp2 = open.document.forms("mainForm", "0").checkPopUpClosed = 1;
//temp2 = document.getElementById("mainForm").checkPopUpClos ed.value;
alert("temp2 = "+temp2);
//alert("checkPopUpClosed 1 = "+top.mainForm.checkPopUpClosed);
//document.mainForm.checkPopUpClosed.value = true;
//alert("checkPopUpClosed 2 = "+document.mainForm.checkPopUpClosed);
}
function checkClick() {
var temp3 = 0;
//temp3 = if(window.opener.closed);
alert("temp3 = "+temp3);
}
</script>
</head>
<body onunload="doAbnormal_Close();" onclick="checkClick();">
<FORM method="post" name="thirdForm" ACTION="2.htm">
<table cellspacing="0" cellpadding="0" summary=".">
<tr>
<td style="text-align:center;">
<br /><br />
<h3>Checking</h3>
<br /><br />
To submit this request click "Save As"
<br /><br />
<INPUT type="submit" name="Save" accesskey="s" alt="ok" onclick="javascript:delayed_close();" VALUE="Save As">
<br /><br />
</td>
</tr>
</table>
</FORM>
<script type="text/javascript">
</script>
</body>
</html>
---------------------------------------------------------------------------------------------
|