>>There is something weird in the way those windows work. When I tried var newWin and newWin.focus() at the end, it didn't work. So, I decided to do the history first and then window.open. It didn't work as well. In both situations, the focus is set back to the original window.
>>
>>If I remove the history, all is ok, however, the original window is blank and I want it to be back to where it was prior to the post.
>
>I made a mistake in the code posted before. Try this one. It works for me.
>Notice the use of 'self' as opposed to 'this'. Sorry.
>
>
>< HTML>
>< HEAD>
>< META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
>< TITLE></TITLE>
>< SCRIPT LANGUAGE=javascript>
>< !--
> function nw(){
> var newWin = window.open("test2.htm","windowname");
> newWin.opener = self
> self.name = "Main"
> window.history.back()
> newWin.focus()
>}
>// -->
>< /SCRIPT>
>
>< /HEAD>
>< BODY>
>
>< P>< input type="button" onclick="nw()" value="NEW WIN"></P>
>
>< /BODY>
>< /HTML>
>
>
>
>This is what I do to try it:
>I access any page in my browser window; then go to this page (via link or entering the URL); then click on the button.
>This is what happens: the new window opens with a page that I created (test2.htm), and the main window goes back to the previous page. The focus stays on the new window.
>
>Let me know if it works for you.
No, it didn't work. Basically, I just sent the function back to the browser from the backend, which is suppose to give the same thing and the focus goes back to the initial window. I also tried to use window.history.back() syntax instead of the window.history.go(-1) syntax. It gave the same result.
The focus goes to the initial window as soon as the called window has finished loading all of its frames. Might it be related?