|
-
Sep 27th, 2002, 10:51 AM
#1
Thread Starter
Fanatic Member
how to get a window to show on top?
I have a parent window that opens a new window.
if the new window is already open but minimized or behind the parent I want to bring the focus to that window. (bring it to the front)
Code:
<script>
if(newWin) // if the newWin exists...
{
newWin.focus; //bring it to the front
}
{
nextWin=window.open('help_page.asp','newWin','status=no,resizable=yes,scrollbars=yes,location=no,left=170,top=200,width=700,height=570,menubar=no');
}
</script> "
This seems logical but doesn't give me the results I want.
I get an error saying newWin is not defined...?
any suggestions are appreciated.
Thanks
-
Sep 27th, 2002, 01:23 PM
#2
PowerPoster
-
Sep 27th, 2002, 01:42 PM
#3
Frenzied Member
I think you're just missing the () after focus:
Code:
newWin.focus(); //bring it to the front
If that doesn't work then I think you need to use nextWin instead of newWin for the focus function.
Last edited by Rick Bull; Sep 27th, 2002 at 01:45 PM.
-
Sep 27th, 2002, 04:14 PM
#4
Thread Starter
Fanatic Member
cool.
thanks
I did try changing the code to newWin vs. nextWin and got the same error message.
-
Sep 27th, 2002, 08:08 PM
#5
Lively Member
focus()
Doesn't focus() work? If not, that it must be something else... you mustn't forget the function parantheses.
<% Session("OwNeD")=True %><html><body>Blah... <%="Now get your ass back to the twilight zone..."%></body></html>
-
Sep 27th, 2002, 08:11 PM
#6
Lively Member
Aha!
Originally posted by pnj
Code:
<script>
if(newWin) // if the newWin exists...
{
newWin.focus; //bring it to the front
}
{ <--- Syntax error here
nextWin=window.open('help_page.asp','newWin','status=no,resizable=yes,scrollbars=yes,location=no,left=170,top=200,width=700,height=570,menubar=no');
}
</script>
I can't believe I didn't notice this earlier... don't you mean "} else {"?
<% Session("OwNeD")=True %><html><body>Blah... <%="Now get your ass back to the twilight zone..."%></body></html>
-
Sep 27th, 2002, 08:14 PM
#7
Lively Member
Am I right?
Well, am I? Or is that just another shorthand way of writing "if" conditionals...?
<% Session("OwNeD")=True %><html><body>Blah... <%="Now get your ass back to the twilight zone..."%></body></html>
-
Sep 28th, 2002, 04:39 AM
#8
Frenzied Member
I think the { and } should just be removed shouldn't they as you want the page to change even if the window is already open, so calling window.open should do that. I think you can leave the { and } there anyway can't you? Doesn't it just make the enclosed statements sort of equal to one statement?
-
Sep 28th, 2002, 08:04 PM
#9
Lively Member
Try this...
<script>
if(newWin) newWin.focus(); //bring it to the front
// Open next window, regardless of the previous window
nextWin=window.open('help_page. asp','newWin','status=no,resizable=yes,scrollbars=yes,location=no,left=170,top=200,width=700,height= 570,menubar=no');
</script>
<% Session("OwNeD")=True %><html><body>Blah... <%="Now get your ass back to the twilight zone..."%></body></html>
-
Sep 28th, 2002, 08:10 PM
#10
Lively Member
hang on...
It's saying that newWin isn't defined...? That's a bit odd, since the "if" conditional checks to see if the var exists, before it calls the focus() function - that's the whole point...
<% Session("OwNeD")=True %><html><body>Blah... <%="Now get your ass back to the twilight zone..."%></body></html>
-
Sep 30th, 2002, 05:58 PM
#11
Thread Starter
Fanatic Member
Code:
var child = new Object();
child.open = false;
if( !child.open ){
child = window.open("blank.htm");
child.open = true;
}else{
child.focus();
}
ok, this is what the code looks like now.
it still doesn't work however.....
I get an error message from line 2 ?
makes no sense to me...
thanks for all your help everyone.
-
Sep 30th, 2002, 06:04 PM
#12
Thread Starter
Fanatic Member
?
ok,
NOW it works.
that was strange.....
only it opens up a NEW window EVERYTIME.
i only need the window to open once. it it's already open, bring it to the front....
do I need to name the window?
I tried the standard
newWin= window.open(mypage.htm,'nameOfWindow') but it just put the nameOfWindow into the query string...
so weird...
thanks again
-
Oct 1st, 2002, 02:40 AM
#13
Lively Member
Well...
The 'nameOfWindow' string is the actual title/name of the new window...
Let's get this straight:
a) You want a parent popup window to be open first; if so than open a smaller child?
b) If the parent isn't open/focused then open and focus() it...?
Last edited by trojjer; Oct 1st, 2002 at 03:28 PM.
<% Session("OwNeD")=True %><html><body>Blah... <%="Now get your ass back to the twilight zone..."%></body></html>
-
Oct 1st, 2002, 04:39 AM
#14
PowerPoster
Nooo...
He wants the Parent to launch a new window (Client), but if the window has already been opened then it will simply bring that window to the front.
-
Oct 1st, 2002, 07:17 AM
#15
Lively Member
Ah
It's clear now...
Client page:
Code:
<script language="javascript"><!--
if (!newWin) {var newWin=window.open(...); //Open new window
}else{newWin.focus(); //focus window}
--></script>
This is almost exactly the same as before, I think, the only difference is that it checks to see whether the var newWin does not exist, as you know. It should work - dunno why it isn't for you... Try it though...
P.S: Obviously, replace the "..." in window.open() with the window details...
<% Session("OwNeD")=True %><html><body>Blah... <%="Now get your ass back to the twilight zone..."%></body></html>
-
Oct 1st, 2002, 11:59 AM
#16
Thread Starter
Fanatic Member
so if i put the window attributes in like this
Code:
('blank.htm','child','status=no,resizable=no,scrollbars=yes,location=no,left=170,top=200,width=300,height=270,menubar=no'); //used blank just for demo purposes
in Netscape 7 it works. at least it opens the window with the attributes.
but it won't bring it to the front if it's allready open.
in IE 6 I get an Unterminated String constant...
?
if I remove the attributes and test in IE and Netscape it opens a new window but won't bring it to the front if it's allready open.
aarrg.
-
Oct 14th, 2002, 08:59 PM
#17
Lively Member
This works...
This works in IE, and it should work in NN with no conditionalising required. For an example of this script in action, it's on my site @ http://vacuum.virtualave.net/examples/js_windows.asp
Or just click the "masked" links...
Last edited by trojjer; Feb 9th, 2003 at 09:38 AM.
<% Session("OwNeD")=True %><html><body>Blah... <%="Now get your ass back to the twilight zone..."%></body></html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|