var projectWindow;
function btnNew_Click() {
var form = document.createElement("form");
form.setAttribute("target", "projectWindow");
form.setAttribute("method", "post");
form.setAttribute("action", "MySite.aspx");
document.body.appendChild(form);
var hiddenField = document.createElement("input");
hiddenField.setAttribute("id", "hiddenValue");
hiddenField.setAttribute("name", "ID");
hiddenField.setAttribute("value", "/*get value from javascript*/");
form.appendChild(hiddenField);
//Below line I added to fix the new input text field that was visible
document.getElementById("hiddenValue").style.visibility = 'hidden';
form.submit();
//The below line i added to give focus if another window is created
// The below code does not work
projectWindow.focus();
//I also tried this:
form.focus();
}
My problem in the above code that i obtained from the thread: http://stackoverflow.com/questions/178964/javascript-post-on-form-submit-open-a-new-window
is that there is an input field that is shown at the client that I cant hide, except for the first time with the line I added (maybe this is about many values return from the method getElementbyId).
The second problem is that I want to set focus in the newly created or reloaded window, currently it is only working with the new window.