Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

How to bring existing window up to front?

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use a html form to retrieve data (a file, located outside of web directory for security). Each time user select a couple of options (from a list), then hit submit button. And the target file will be displayed in an existing window(if such window doesn't exist, open new one). Everything seems work fine but I run into two problems.
1. how to bring the existing window up to front?
2. how to restore the existing window (which was minimized) from bottom status to front?
Thank you very much for your any help.
Here is my script to open new window and target attribute in html form.
<script language="JavaScript">
function openBrWindow(winName,features)
{ var win = window.open(winName,features);
win.focus();
}
</script>

target="openBrWindow('invoiceFile','scrollbars=yes,resizable=yes,width=450,height=350');"
Jason
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jason,
I made it work by adding a filename to window.open(...) and calling the function with an on_click. See below..

Originally posted by Jason Wang:
<script language="JavaScript">
function openBrWindow(winName,features)
{ var win = window.open("test.html",winName,features);
win.focus();
}
</script>
on_click="openBrWindow('invoiceFile','scrollbars=yes,resizable=yes,width=450,height=350');"



hth,
g.
 
Jason Wang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help. But it doesn't solve my problems.
Jason
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try if this works for u....
<script>
win=""
function openBrWindow(winName,features) {
if(win){
win.focus();
}
else{
win = window.open(winName,features);
}
</script>
Hope it does!!
 
Jason Wang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I don't understand your code.
Actually my code worked. But it can't solve two problems.
1. bring that display window from behind to front (if the display window is behind)
2. restore the display window if it is minimized.
Thanks a lot.
Jason
 
Garann Means
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jason Wang:
Thanks for your help. But it doesn't solve my problems.
Jason


Could you be more specific about what your problems are? The code I offered does what you appear to be asking for on my machine - perhaps you could go into more detail about what isn't working in your setup?
 
Jason Wang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, i have to use target attribute so onClick event doesn't work for my case.
Now, my code can work like:
after a user selects some options from parent window and clicks submit button, then the invoked servlet accesses a file and dump all data into a new window(for displaying data). if the window named as 'invoiceFile' doesn't exist then creates one, otherwise just use the existing window.
But now I need two more functionalities:
1. if the user changes options from parent window to do another query, then hits submit button again. You know what happens. the target window (called invoiceFile) is behind the parent window even though new data is in it. BUT I need it being brought front.
2. user minimizes 'invoiceFile' window before he does operations described in 1. What the user sees now is parent window and the target window icon in bottom status window. HOWEVER I need it being restored and brought to front.
Hopefully, my question is clearly explained this time. I guess my question is a bit tough.
Thanks again for you guys' time and assistance.
Jason
[ September 11, 2002: Message edited by: Jason Wang ]
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add this to the html document being sent to the child window from the server:
function fooMe{width,height)
window.resizeTo(width,height);//set size
window.focus();//set focus
}

<body on load=fooMyWindow(800,600);>
I must be missing something? This seems very simple.
btw you have to remove the space between on load
in body on load
 
Jason Wang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is that simple? Not really. It seems you didn't understand my question. I said I have to use
<form name="form1" method="post" action="getFileData" target="jsfuncName()" > in parent windown. Anything else(onLoad or onClick) doesn't work for my case.
Anyway, thanks for your time.
Jason
 
Charlie Sturman
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jason,
I think there is some confusion,please read this post very carefully.
when the action,getFileData, responds with an html document that goes to window,jsfuncName(),
this html document will be loaded into the target window.This document that gets loaded into,jsfuncName(), contains the code from my post.
the onload event handler is not in the same window as the form.

<form name="form1" method="post" action="getFileData" target="jsfuncName()" > in
 
Charlie Sturman
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a working example of a solution is worth a 1000 posts
Here it is:
http://www21.brinkster.com/sturman/javaranch/parent.html
 
Jason Wang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Charlie, thanks a lot for your instructions. Yes, I misunderstood you. I thought onLoad event handler is put in the form page. Now I understand how it works with html but I am not sure if it also works with PDF file (I mean if my source file is PDF).
Have a great day!
Jason
[ September 12, 2002: Message edited by: Jason Wang ]
 
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quickly glancing over these posts I didn't seem to come across this (excuse me if I missed it) ... what if the window was opened by another window and you refreshed the parent window? The variable referencing the new window will be re-initialized. What way do you reference the window afterwards? Also, if you have code that generates the new windows contents (in the parent window) how do you overwrite the contents in the new window by the generating code in the parent window?
Rob
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
The trailboss has a kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic