focus

Subscribe to focus 2 posts, 2 voices

 
no0n Scriptwright

I'm injecting a form into a web page and the onsubmit action opens a new window. I want the focus to stay on the page that the form was injected to instead of switching to the new window that was created.

I've tried

window.open('http://google.com/search?q='+this.imdbSearch.value+'','IMDBWindow');
window.setTimeout('this.focus();',500);
return false;
window.open('http://google.com/search?q='+this.imdbSearch.value+'','IMDBWindow');
window.setTimeout('window.focus();',500);
return false;
window.open('http://google.com/search?q='+this.imdbSearch.value+'','IMDBWindow');
window.setTimeout('opener.focus();',500);
return false;
window.open('http://google.com/search?q='+this.imdbSearch.value+'','IMDBWindow');
window.setTimeout('self.focus();',500);
return false;

All of these were tried with and without setTimeout.

 
Yansky Scriptwright

Try the blur method: http://www.javascriptkit.com/jsref/window.shtml