By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,190 Members | 2,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,190 IT Pros & Developers. It's quick & easy.

PopUp Focus - How To?

P: n/a
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

Jul 23 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
Ivo
<th************@hotmail.com> wrote
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
--
ivo
Jul 23 '05 #2

P: n/a
In article <11**********************@c13g2000cwb.googlegroups .com>,
th************@hotmail.com enlightened us with...
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

Jul 23 '05 #3

P: n/a
theintrepid...@hotmail.com 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>

Jul 23 '05 #4

P: n/a
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.

Jul 23 '05 #5

P: n/a
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

Jul 23 '05 #6

P: n/a
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

Jul 23 '05 #7

P: n/a

theintrepid...@hotmail.com wrote:
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.

Jul 23 '05 #8

P: n/a
God! Are you all human rights activists? Go back play with your Apple
Mac!

Jul 23 '05 #9

P: n/a
God! Are you all human rights activists? Go back play with your Apple
Mac!

Jul 23 '05 #10

P: n/a
theintrepid...@hotmail.com wrote:
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>

Jul 23 '05 #11

P: n/a
In article <11**********************@g14g2000cwa.googlegroups .com>,
th************@hotmail.com enlightened us with...
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

Jul 23 '05 #12

P: n/a
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.

Jul 23 '05 #13

P: n/a
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

Jul 23 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.