Code:
<script language="javascript">
function CloseAndReturn(sectionID){
if (window.opener) // if the background window is still open, continue
{
var url=window.opener.location.href; // url of the background window
if (url.indexOf("sec=")>-1) // if the background url contains "sec"
{
var firstpart;
var middlepart;
var lastpart="";
firstpart=url.substring(0,url.indexOf("sec=")); // everything before "sec"
middlepart=url.substring(url.indexOf("sec=")); // everything including and after "sec"
if (middlepart.indexOf("&")>-1) // if there is "&" in middlepart
lastpart=middlepart.substring(middlepart.indexOf("&")); // lastpart is everything including and after "&"
window.opener.location.href=firstpart + "sec=" + sectionID + lastpart; //sets the new url for the background page
}
else // "sec" is not in the URL, make a new URL with it
{
if (url.indexOf("?")==-1) // if there is no query string
window.opener.location.href=url + "?sec=" + sectionID; // add query string "?sec=..."
else // if there is a query string
window.opener.location.href=url + "&sec=" + sectionID; // add query string "sec=..."
}
window.close(); // close this window
}
}
</script>
I hope that helps