Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.opener madness

Status
Not open for further replies.

JuanitaC

Programmer
Feb 21, 2001
292
CA
I have been searching the this forum trying to find the solution to my problem. This thread thread216-84313 seems to be the same problem, but doesn't give a solution.

To start, I am using IE 5.5 on a Windows 2000 machine.

Here is the problem:
I have two pop-up windows opened from another pop-up window (Product and Client are opened from Sales). The onUnload event on both Product and Client set hidden fields on Sales before closing the pop-up. The function on Product works (existing code, not written by me), and the code on Client doesn't. I keep getting "objParentWindow.document.frmSales.txtClientID is null or not an object." To me, they look exactly the same. Any ideas?

Here are the pertinent parts of the files:

SALES.asp
<script language=&quot;javascript&quot;>
function cmdProduct_OnClick()
{
strURL = &quot;Product.asp?prodID=&quot; + window.document.frmOpportunity.cboProduct.options[window.document.frmOpportunity.cboProduct.selectedIndex].value + &quot;&ManufID=&CategoryID=&OppoID=<%=intOppoID%>&projid=<%=intProjectID%>&Source=<%=strSource%>&quot;;
window.open (strURL,'NewProduct','left=20,top=45,height=400,width=780,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,titlebar=yes')
}

function cmdClient_OnClick()
{
strURL = &quot;Client.asp?contractorID=&quot; + window.document.frmOpportunity.cboTileContractor.options[window.document.frmOpportunity.cboTileContractor.selectedIndex].value + &quot;&OppoID=<%=intOppoID%>&projid=<%=intProjectID%>&Source=<%=strSource%>&quot;;
window.open (strURL,'Client','left=20,top=45,height=140,width=400,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,titlebar=yes')
}
</script>
...
<form name=&quot;frmSales&quot; method=&quot;post&quot; action=&quot;sales.asp&quot;>
<input type=&quot;hidden&quot; name=&quot;txtClientID&quot;>
<input type=&quot;hidden&quot; name=&quot;txtProductID&quot;>
...
<input type=&quot;button&quot; value=&quot;Add/Edit Client&quot; name=&quot;cmdClient&quot; OnClick=&quot;cmdClient_OnClick()&quot;>
<input type=&quot;button&quot; value=&quot;Add/Edit Product&quot; name=&quot;cmdProduct&quot; OnClick=&quot;cmdProduct_OnClick()&quot; tabindex=&quot;8&quot;>

</form>



PRODUCT.asp -- onUnload function works
function onunload(){
if (&quot;<%=intProjectID%>&quot; != &quot;&quot;){
objParentWindow = window.opener.parent.window;
objParentWindow.document.frmSales.txtProductID.value = &quot;<%=intProductID%>&quot;;
objParentWindow.document.frmOpportunity.submit();
}
}
Called on
<body onunload=&quot;return window_onunload()&quot;>


CLIENT.asp --- onUnload function does not work.
function window_onunload()
{
if (&quot;<%=intProjectID%>&quot; != &quot;&quot;){
objParentWindow = window.opener.parent.window;
objParentWindow.document.frmSales.txtClientID.value = &quot;<%=intCompetitor%>&quot;;
objParentWindow.document.frmOpportunity.submit();
}
}

Called by
<body onunload=&quot;return window_onunload()&quot;>
 
the only thing I can think of suggesting is to take the function name on the CLIENT.asp and change it from &quot;window_onunload()&quot; to &quot;onunload()&quot; like it appears in the PRODUCT.asp. Like you say the functions are identical, so if that does not work I would like to see what else is inside both those files.

Martin If the sky is blue and the Sun is yellow.... Why isn't the air Green?
 
Thanks for your help... I think I found the problem. The onUnload function was being called twice (once when the Client window refreshed and once when it closed). I think that the Sales page was not fully loaded before the onUnload function tried to access the page the second time. Fixed up the rest of the code and it all seems to work now!

A good test of my debugging skills anyway :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top