Hi.
I've written a function which sets a variable (ParentWin) equal to the current window's opener. If an opener does'nt exist it opens a new window and sets the ParentWin as that. This gaurantees there's another open window that can referenced.
I've written a 2nd function, which takes two parameters and sets form field values in ParentWin equal to the parameters. This works too.
Both functions don't work together if ParentWin is'nt already open. I think the 2nd function needs calling within setTimeout() to allow the window to fully open first . Whenever I try this I get errors though.
In summary I want to 1) Set or open Parent Win 2)Update form fields values in Parent once or provided it's open.
Has anyone come up against a problem like this. If you've got working code I could borrow and adapt that would be ideal.
Here's the 2 functions:
var ParentWin
function setParentWin()
{if (ParentWin && !ParentWin.closed)
{//ParentWin is open - no action needed
}
else if (opener && !opener.closed)
{//Set ParentWin as the page that opened this window
ParentWin = opener;
}
else
{//Open a new Parent Window and call it ParentWin
ParentWin = window.open('TestParent.asp','Outputs','');
}}
function populateParent(projectID, projectTitle)
{
setParentWin();
ParentWin.focus();
ParentWin.OutputsForm.ProjectID.value = projectID;
ParentWin.OutputsForm.ProjectTitle.value = projectTitle;
}
Thanks for your time
I've written a function which sets a variable (ParentWin) equal to the current window's opener. If an opener does'nt exist it opens a new window and sets the ParentWin as that. This gaurantees there's another open window that can referenced.
I've written a 2nd function, which takes two parameters and sets form field values in ParentWin equal to the parameters. This works too.
Both functions don't work together if ParentWin is'nt already open. I think the 2nd function needs calling within setTimeout() to allow the window to fully open first . Whenever I try this I get errors though.
In summary I want to 1) Set or open Parent Win 2)Update form fields values in Parent once or provided it's open.
Has anyone come up against a problem like this. If you've got working code I could borrow and adapt that would be ideal.
Here's the 2 functions:
var ParentWin
function setParentWin()
{if (ParentWin && !ParentWin.closed)
{//ParentWin is open - no action needed
}
else if (opener && !opener.closed)
{//Set ParentWin as the page that opened this window
ParentWin = opener;
}
else
{//Open a new Parent Window and call it ParentWin
ParentWin = window.open('TestParent.asp','Outputs','');
}}
function populateParent(projectID, projectTitle)
{
setParentWin();
ParentWin.focus();
ParentWin.OutputsForm.ProjectID.value = projectID;
ParentWin.OutputsForm.ProjectTitle.value = projectTitle;
}
Thanks for your time