I want to create a "popup window" that get focus each time the button is clicked. The function below executes fine from an onclick
event but does not execute as expected when the parent page is refreshed and executed from an onload event.
here is my function:
function PopupDelete(delete_images)
{
var win = window.open('URL','PopupDelete','width=500,height=400,scrollbars=yes');
win.focus();
}
So if I use this from the button below it works as expected.
<input type="button" name="delete" value="Images" class="smallbutton" onclick="PopupDelete(delete_images);">
Now the problem I am having is we are using another method called set_mode on the button instead of directly calling the PopupDelete
function.
function set_mode(mode)
{
document.MASTER.mode.value = mode;
document.MASTER.submit();
}
<input type="button" name="delete" value="Images" class="smallbutton" onclick="set_mode('delete');">
It sets the mode in the master form as Delete and submits the form. The landing page is the same page where the form is. So it does some php validation and executes the PopupDelete
function with onload
method within the body tag.
<body onload='PopupDelete(delete_images)'>
If there was no pop up window open it works fine but if the pop up window was already open and minimized, then the pop up window does not get the focus. The funny thing is it does recognized and updates the contents rendered on the pop up window but does not recognize the .focus().
Any suggestions will be widely appreciated.