Simple javascript function help

I am using a simple function on the onclick of a hyperlink
 
<li><a href="javascript:cliedit()">Client Edit</a></li>

Open in new window


This opens an edit record page.   When I close that page I want another function (gogetit)  to execute. gogetit is currently running before the next page closes.  Gogetit does an ajax update.
function cliedit()
{
var cs=document.getElementById("conno").value;
var urlstring="?cSearch="+cs;
open("https://www.myvcaccount.com/cgi-bin/upclient.exe"+urlstring , "", "toolbar=no,menubar=no,width=800,height=425,resizable=no");
gogetit(cs);}

Open in new window


So how do I get it to run after I close the page.

Thanks
]
CharlietnAsked:
Who is Participating?
 
experts1Connect With a Mentor Commented:
Just to follow-up:

Maybe you might want to include the "gogetit(cs)" function
on the child window page and execute the "gogetit(cs)" function
within the said child window "onbeforeunload" function instead as follows:

<script language="javascript">
 window.onbeforeunload = function() {
   window.opener.focus();
   //alert('onunload event');
 gogetit(cs);
}

function gogetit(x) {
   // Blah...blah !
  // Do whatever Ajax crazy stuff etc.. !
}

Of coures you would remove the "gogetit(cs)" function call
from the parent window.
0
 
experts1Commented:
Below is example of parent and child windows, where closing child window will  
return focus to parent window.

Code for PARENT window below:
<html>
<head>
<title>Close Child Window Show Parent</title>
<script language="javascript">
  var main_win;
function win_child()
{
//var cs=document.getElementById("conno").value;
//var urlstring="?cSearch="+cs;
main_win=window.open("child_window.html", "myWin", "toolbar=no,menubar=no,width=800,height=425,resizable=no");
main_win.focus();
//gogetit(cs);
}
</script>
</head>
<body>
<br>
<input type=button value="Child_Screen" onClick="win_child()">
<br>
<input type=button value="Child_Focus" onClick="javascript:main_win.focus();">
</body>
</html>

Code for CHILD window below:

<html>
<head>
<title>Child_Window</title>
<script language="javascript">
 window.onbeforeunload = function() {
   window.opener.focus();
   alert('onunload event');
}

 function showParent() {
   window.opener.focus();
}
</script>
</head>
<body onunload=" window.opener.focus();">
<br>
<input type=button value="Show_Parent" onClick="showParent()">
<br>
</body>
</html>
0
 
CharlietnAuthor Commented:
I am sorry but I don't follow this.  Is this correct

var main_win;
function win_child()
{
var cs=document.getElementById("conno").value;
var urlstring="?cSearch="+cs;
main_win=window.open("https://www.myvcaccount.com/cgi-bin/upclient.exe"+urlstring , "Client Data", "toolbar=no,menubar=no,width=800,height=425,resizable=no");
main_win.focus();
gogetit(cs);
}

Open in new window

0
 
experts1Commented:
Correct!

This function will open the child window object "main_win" and
ensure that focus is set on the said child window "main_win".

Sorry, my the choice of name should have been "child_win",
but you may change it if you wish.
0
 
CharlietnAuthor Commented:
Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.