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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Classic Problem. Window.Open + onBlur=window.focus() + form Element :

Status
Not open for further replies.

RhythmAddict112

Programmer
Jun 17, 2004
625
US
Hi All,
_I've been everywhere searching for a solution to this...So basically I'm just going to run through my problem, though I'm not sure there is a solution (at least while still using window.open)_

Okay, I'm using window.open to pop a window up...intranet audience all on IE6.xx, but the window I am popping up has form elments and therefore submits. Naturally, the using window.showModalDialog pops up a new window when the form is submitted. Basically, I need a way to use window.open and keep that window on top while still allowing the user to access the text area on the popped up window. I'm [italic]kind of[/italic] stuck with window.open because my child window does a self.close and then redirect's my parent window (and thus refreshing to show content that was just entered)


MainPage [window.Open]--> EditPage (form) [submit]--> write to DB then self.close and redirect MainPage back to itself

Any ideas appreciated ...Please let me know if I was not clear...thank you in advance

All hail the INTERWEB!
 
I'm not 100% sure what you're asking by the problem description. This part especially confused me:
Basically, I need a way to use window.open and keep that window on top while still allowing the user to access the text area on the popped up window.
If you're using window.open to pop up a window and you want to allow access to the text area in the popped up window then this shouldn't be an issue because the popped up window would have focus when it was opened. If by chance you mean that you want the popped up window to remain on top while still allowing access to the main page, then you probably want to use showModelessDialog instead. Here's a link:



-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Hi,
Thanks for the response. Let me try and clarify. Essentially, I want the effects of showModalDialog (ie, ensure the popup remains on top) However, I am using window.open instead. I need to use window.open instead of showModalDialog because if I have a form in my Modal window, when the form is submitted a new window is created. With window.open, a new window is not created.

If I put this code into my popup window...
Code:
<body onBlue="window.focus();">

Then the window I have opened using window.open stays on top. Which is great, however since I have a form element (textarea) on my popup window, everytime I focus on it - focus is diverted back to the window thus, not allowing the user to enter any information.

Example Code:
MainPage.htm:
Code:
<HTML>
<HEAD>
	<meta http-equiv=pragma content=no-cache>
  
 
</HEAD>
<BODY>

	<h2>ExampleCode</h2>
Window.Open:
 <input type=button class=button onclick='window.open("myPopUp.htm","orig","scrollbars=no,menu=no,status=no");' value="Window.Open" style=width:50;> 
 
Modal:
 <input type=button class=button onclick="window.showModalDialog('myPopUp.htm','winLStatus','dialogHeight: 450px; dialogWidth: 450px; edge: Raised; center: Yes; help: No; status: No; resizable: No;');" value="Modal">
</BODY>
</HTML>

myPopUp.htm
Code:
<HTML>
<HEAD>
	<meta http-equiv=pragma content=no-cache>
  
 
</HEAD>
<BODY onBlur="window.focus();">

	<h2>ExampleCode</h2>
 <form method="post" action="somePage.htm">
 
 <input type=button class=button onclick='window.open("myPopUp.htm","orig","scrollbars=no,menu=no,status=no");' value=Delete style=width:50;> 




 <input type="textarea" name="whatever">
 <input type="submit" value="submit"
 </form>
</BODY>
</HTML>

I think that should pretty much illustrate my issue...Please let me know if it does not...

All hail the INTERWEB!
 
Just in case someone finds this thread via a search...
My solution was to eliminate the submit button, and change it to <input type="button" .. onClick="submitPage();">

And then simply "manually" submit the page by putting all the values onto the querystring, and redirecting to the page that you need to (the page that your "action=" points to...)

J/S code:
Code:
submitPage(theForm)
{
//submit it...open the window way off viewable screen
 window.open("submitPage.asp?id=" + theForm.lin.value  + "&own=" + theForm.selOS.value + "&typ=" + theForm.typ.value,"lownr","left=9999,top=9999");
//Close the window you just opened
 window.close();
}

Then, simply go back to use showModalDialog - which will keep the form on top.

All hail the INTERWEB!
 
I would handle this situation by using a "floating" div or iframe instead. Since it is technically part of the page, it will always stay with the page, and once you unhide it, it will stay on top of the page until you hide it again. If you really want to, you can make it look pretty close to a dialog box with a few graphics and some css. You can even make it draggable, so people can move it anywhere they want on the page.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Indeed you could do that...and here is a nice example of such an instance...

It's really just a matter of preference, though I don't think the iframe idea would involve code that was dramatically different, ie...
I would need to specify the location of my "action" page because I'm changing based on the users actions...
Code:
window.frames['ifName'].location.href = "myActionPage.asp?selOrders=" + document.frmOwner.selOrders.value + "&selOS=" + document.frmOwner.selOS.value etc...;

thanks for your input

All hail the INTERWEB!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top