Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 windows, back to first without reloading? 1

Status
Not open for further replies.

indigojo

Technical User
Jan 16, 2001
11
AU
OK, i have 2 pages, one is a search console, the other is a javascript new window which opens when user presses search. we want to have a back button on the results page that returns the user back to the search console which is still open without reloading it every time. i know this can be done but need some help with the code if any one can help, or point me to a site using something similar. thanks in advance
 
If the window is still open, and you still have a reference to it (say, 'x') and all it has done is lost focus, then all you need to do is say:

x.focus();

Is that what you were looking for?
 
i am not sure, say for example i have the following situation search.htm which the client sees first, he searches on bananas and gets a new window opened (banana.htm of course)about bananas. on the top of the banana.htm there is a back button which sends the client back to search.htm (at the moment this is just calling the url and thus reloading the search page) I want to provide a back button that uses javascript which just pops the search window to the front (as it is still open and prevents the need for the page to be reloaded) Hope this makes better sense of what i am trying to do.
 
Ok -- let me draw this example --

Say I have a page, and I want to open up a popup:

<script>
var x = window.open('banana.htm', bananaWindow');
</script>

Now I have a reference to the window on my main page -- that's the key to controlling it.

Then, once that window is open, I can put this script on banana.htm in order to transfer focus back to the search.htm page --

window.opener.focus();

and likewise, I can give focus back to banana.htm from search.htm by saying:

x.focus();

I hope that makes it clearer. :)
Paul Prewett
 
i see, yes that does make it clearer, much appeciative of your help. thanks
 
Alright then, BUT:
How do I forward the window-handle to another page?
Say, when I call a page from 'banana.htm', I'd like to keep the handle for 'search.htm'.

- no frames at all!
- no back-button-functionality!

ANY help appreciated.
URGENT!
 
GirlFriday here.... I asked this question today as well, but I tried the .focus() and it didn't work. The only noticable difference (that I can see) is that the error box now is greyed out, although it still works.
 
all : just close the pop up and the main window will be focused
maak : if you remain in the popup windows (say : banana.htm calls maakluk.htm, but target=&quot;_self&quot;) , search.htm will still be known as &quot;opener&quot;. If the link modifies the opener, then you have to &quot;save&quot; somehow search.htm : either in a hidden frame, or in a hidden field, or (if you use any server side langage) in a session/application variable
 
2 iza:
> [...]
> you have to &quot;save&quot; somehow search.htm :
> either in a hidden frame, or in a hidden field [...]

just as I expected...
Unfortunately you cannot save such a handle in a form element, since it is of no displayable type.

Seems I have to use frames anyway...

But thx for your replies.
 
so yes, save it in a hidden frame ... let me know how you manage !
 
It's just as simple as setting up a variable in that mystique frame, and then assigning to it the return-value of the window-opening function of the main frame:

&quot;hidden&quot; frame:
...
var savedhandle;
...

&quot;main&quot; frame:
...
parent.frames[&quot;hidden&quot;].savedhandle=window.open(&quot;file.html&quot;,&quot;file.name&quot;);
...

Everything works beautyfully :)

cu, maak.
 
great ! i'm happy it works for you now :))))
and, than you for writing down the solution here - this way, anyone with the same problem you had can now fix it quickly ;]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top