Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The window.history takes focus now
Message
From
07/06/2001 19:02:53
 
 
To
07/06/2001 15:44:13
General information
Forum:
Internet
Category:
Javascript
Miscellaneous
Thread ID:
00516591
Message ID:
00516698
Views:
17
>One HTML page is calling a backend application which returns an HTML page containing some javascript code. That code is using window.open syntax to call another page in its own window. Normally, when returning that code, I also send window.history.go(-1) to force the originated page to go where it was prior to calling the transaction.
>
>This works for a while. Now, probably related to the time that the new window is taking to open and load everything, when the window.history.go(-1) is done on the orignated page, the focus is also activated on that page. Before, the history was doing its process in the back. Now, the history activates the focus. So, the new window opened only appears for a second and looses its focus. How can I force it to keep its focus? In order word, the main goal here is to have the orignated window to go back where it was before posting the form without affecting the new window opened in regards to its focus.


You could simply call the window.open to open another window, which seems to be what you want to accomplish anyway, right? For example, in the original page returned from the server, your code would look like this:
var newWin = window.open(newURL,windowname,[new window options])   //windowname can be anything
this.name = 'main'   //so you can refer to this page from the new window
newWin.opener = this   //not necessary, but I always use just in case...
newWin.focus()  //to make sure the new window takes focus
If you are posting information to this new window, from a form in the original window, you can use the TARGET attribute of the FORM to point to this new window. If you open the new window first (in case you want it to be a specific size, etc.), you would use the new window's name ('windowname' in code above) as the TARGET attribute of the form. In this scenario, the original window, with the form, will never change, but the URL that you list in the ACTION attribute will simply open in the new window and process the request. After that, you can access either window using the names assigned. For example, if you wanted to manipulate the original window from the new window, you could do:
this.opener.location.href = 'anotherURL.htm'
Hope this helps.
Andres M. Chiriboga, MCSE, MCP+I
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform