PopUp Focus - How To?

T

theintrepidfox

Dear Group

I wondered whether you can help me with this. I do have a page that
contains a button and an IFrame. The IFrame contains a dummy page that
is set to redirect to a word document when loaded so eventually the
word document will be displayed in the IFrame. That works all well. No
problem.

The only trouble I have is with the button contained on the parent
page. When pressed, it runs this script:

<script language=JavaScript>
window.open('download.aspx','download','width=320,height=150,resizable=no,scrollbars=no');</script>

which opens a little download window where the word document can be
downloaded to the client. The window opens perfectly fine but always
ends up behind the parent page because the button click unavoidable
reloads the parent page (That's ok) but then triggers the dummy page to
load the document which will give the focus to the paren page. So the
pop-up is only shown for a second in the foreground and then
disappears.
I have tried placing a window.focus(newwindow) script on the dummy page
but then I can't see the pop-up at all. I might do something wrong with
the window.focus script as I'm not so good in Java.
If you have any ideas, please let me know.

Thank you very much for your help & efforts!
Have a nice day!

Martin
 
I

Ivo

The only trouble I have is with the button contained on the parent
page. When pressed, it runs this script:

<script language=JavaScript>
window.open('download.aspx','download','width=320,height=150,resizable=no,sc
rollbars=no');</script>

Why should your popup be unresizable? There really is no excuse for
disabling this window feature, simply because those visitors that don't try
to resize the window will never notice a difference, and those that do try
it, for whatever unthought of circumstance, will only find that they can't!
Give me one good reason!
which opens a little download window where the word document can be
downloaded to the client. The window opens perfectly fine but always
ends up behind the parent page because the button click unavoidable
reloads the parent page (That's ok)

Haven't seen enough of your code, but I don't see why a reload would
unavoidable. Anyway, to focus the popup from the opener, you need to assign
a reference via the open() statement like so:

var w=window.open( 'stuff', 'stuff', 'stuff' );
w .focus();

hth
 
K

kaeli

So the
pop-up is only shown for a second in the foreground and then
disappears.

Did you try: (watch for word-wrap!)

<script type="text/javascript">
// note that the language attribute is deprecated: use type

var w = window.open('download.aspx','download','width=320,height=
150,resizable=no,scrollbars=no');
if (w != null) w.focus();

</script>

--
--
~kaeli~
Jesus saves, Allah protects, and Cthulhu thinks you'd make
a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
R

RobB

(e-mail address removed) wrote:

(snip)
...the button contained on the parent
page....runs this script:
(snip)

which opens a little download window where the word document can be
downloaded to the client. The window opens perfectly fine but always
ends up behind the parent page because the button click unavoidable
reloads the parent page (That's ok) but then triggers the dummy page to
load the document which will give the focus to the paren page. So the
pop-up is only shown for a second in the foreground and then
disappears.

(snip)

Wow, that's as clear as mud. Why does the "button click unavoidable
[sic]
reloads the parent page" ? If it's a <button> button, try this:

<button...onclick="funcName();return false;">

Otherwise, try this in 'download.aspx':

<script type="text/javascript">

self.focus();

</script>
 
T

theintrepidfox

Ivo

First, thanks very much for your reply.
But may you want to have a look out of your box next time before
starting patronizing.
It's an aspx application and if I don't want someone to resize a window
then there's a very good reason for it. And if I say a reload is
unavoidable then this is also carved in stone! You java people and your
attitude. Argh! Anyway, tried your suggestion before and it doesn't
work.
 
T

theintrepidfox

Hi Kaeli

Thanks very much for your help.
Yes I tried that. Even on a simple test page with two buttons. One
opens the popup and the other one gives the focus to it with the code
you suggested. However I always get a variable null error. Thought the
variable is global and should have a value if I did everything like you
say? Any ideas?

Thanks for your efforts!

M
 
T

theintrepidfox

Hi Rob

Thanks for your post!
Well, it's an aspx application that will need to post back when the
button is clicked. It's not just a button but a toolbar control and
that how it works. So everytime the button is clicked it executes the
javascript to open the popup (which will come up for a second) but
because the page reloads it also reloads the frame with the dummy page
that will then reload the word document and the parent page gets the
focus again!

Have tried your suggestion and it doesn't work because the frame reload
happens after the popup comes up so this will be after the popup focus
event has happened. Tried placing a timer in the popup to execute the
javascript after e.g. five seconds (when the frame finished loading)
but still no luck.

Have a nice day!

M
 
M

Matthew Lock

It's an aspx application and if I don't want someone to resize a window
then there's a very good reason for it. And if I say a reload is
unavoidable then this is also carved in stone! You java people and your
attitude. Argh!

Remember that you have no right on usenet to demand to have your
questions answered under your terms.
 
R

RobB

Hi Rob

Thanks for your post!
Well, it's an aspx application that will need to post back when the
button is clicked. It's not just a button but a toolbar control and
that how it works. So everytime the button is clicked it executes the
javascript to open the popup (which will come up for a second) but
because the page reloads it also reloads the frame with the dummy page
that will then reload the word document and the parent page gets the
focus again!

Have tried your suggestion and it doesn't work because the frame reload
happens after the popup comes up so this will be after the popup focus
event has happened. Tried placing a timer in the popup to execute the
javascript after e.g. five seconds (when the frame finished loading)
but still no luck.

Have a nice day!

M

Could make that popup a $0.98 modal window:

<script type="text/javascript">

self.onblur = function()
{
setTimeout('self.focus()', 100);
}

</script>
 
K

kaeli

Hi Kaeli

Thanks very much for your help.
Yes I tried that. Even on a simple test page with two buttons. One
opens the popup and the other one gives the focus to it with the code
you suggested. However I always get a variable null error. Thought the
variable is global and should have a value if I did everything like you
say? Any ideas?

Thanks for your efforts!

Might be an issue b/c of the reloading going on (which wipes out variable
values). Or might be timing if the document hasn't fully loaded.

You just want the popup to focus when it's loaded, right?

Did you try, in the popup itself (that is, in download.aspx):
<body onload="self.focus();">

--
~kaeli~
Cthulhu saves our souls and redeems them for valuable
coupons later.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
T

theintrepidfox

Thanks for your message Rob. I havent tried your suggestion but will if
the current one causes problems. I found a workaround by setting a META
refresh and self.focus() in the popup.
 
T

theintrepidfox

Thanks for your message Kaeli.

Yes, that's right! That might be why the variable will be empty!

I found a workaround by setting a META refresh and self.focus() in the
popup.

Have a nice day!

M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top