PopUp Focus - How To?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • theintrepidfox@hotmail.com

    #1

    PopUp Focus - How To?

    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=JavaSc ript>
    window.open('do wnload.aspx','d ownload','width =320,height=150 ,resizable=no,s crollbars=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(ne wwindow) 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

  • Ivo

    #2
    Re: PopUp Focus - How To?

    <theintrepidfox @hotmail.com> wrote[color=blue]
    > The only trouble I have is with the button contained on the parent
    > page. When pressed, it runs this script:
    >
    > <script language=JavaSc ript>
    >[/color]
    window.open('do wnload.aspx','d ownload','width =320,height=150 ,resizable=no,s c
    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!
    [color=blue]
    > 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)[/color]

    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


    Comment

    • kaeli

      #3
      Re: PopUp Focus - How To?

      In article <1109078256.292 279.227920@c13g 2000cwb.googleg roups.com>,
      theintrepidfox@ hotmail.com enlightened us with...[color=blue]
      > So the
      > pop-up is only shown for a second in the foreground and then
      > disappears.[/color]

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

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

      var w = window.open('do wnload.aspx','d ownload','width =320,height=
      150,resizable=n o,scrollbars=no ');
      if (w != null) w.focus();

      </script>

      --
      --
      ~kaeli~
      Jesus saves, Allah protects, and Cthulhu thinks you'd make
      a nice sandwich.



      Comment

      • RobB

        #4
        Re: PopUp Focus - How To?

        theintrepid...@ hotmail.com wrote:

        (snip)
        [color=blue]
        > ...the button contained on the parent
        > page....runs this script:[/color]

        (snip)
        [color=blue]
        > 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[/color]
        to[color=blue]
        > 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.[/color]

        (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...oncli ck="funcName(); return false;">

        Otherwise, try this in 'download.aspx' :

        <script type="text/javascript">

        self.focus();

        </script>

        Comment

        • theintrepidfox@hotmail.com

          #5
          Re: PopUp Focus - How To?

          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.

          Comment

          • theintrepidfox@hotmail.com

            #6
            Re: PopUp Focus - How To?

            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

            Comment

            • theintrepidfox@hotmail.com

              #7
              Re: PopUp Focus - How To?

              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

              Comment

              • Matthew Lock

                #8
                Re: PopUp Focus - How To?


                theintrepid...@ hotmail.com wrote:[color=blue]
                > It's an aspx application and if I don't want someone to resize a[/color]
                window[color=blue]
                > 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[/color]
                your[color=blue]
                > attitude. Argh![/color]

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

                Comment

                • theintrepidfox@hotmail.com

                  #9
                  Re: PopUp Focus - How To?

                  God! Are you all human rights activists? Go back play with your Apple
                  Mac!

                  Comment

                  • theintrepidfox@hotmail.com

                    #10
                    Re: PopUp Focus - How To?

                    God! Are you all human rights activists? Go back play with your Apple
                    Mac!

                    Comment

                    • RobB

                      #11
                      Re: PopUp Focus - How To?

                      theintrepid...@ hotmail.com wrote:[color=blue]
                      > 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[/color]
                      page[color=blue]
                      > 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[/color]
                      reload[color=blue]
                      > happens after the popup comes up so this will be after the popup[/color]
                      focus[color=blue]
                      > 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[/color]

                      Could make that popup a $0.98 modal window:

                      <script type="text/javascript">

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

                      </script>

                      Comment

                      • kaeli

                        #12
                        Re: PopUp Focus - How To?

                        In article <1109119550.102 687.140600@g14g 2000cwa.googleg roups.com>,
                        theintrepidfox@ hotmail.com enlightened us with...[color=blue]
                        > 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!
                        >[/color]

                        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.fo cus();">

                        --
                        ~kaeli~
                        Cthulhu saves our souls and redeems them for valuable
                        coupons later.



                        Comment

                        • theintrepidfox@hotmail.com

                          #13
                          Re: PopUp Focus - How To?

                          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.

                          Comment

                          • theintrepidfox@hotmail.com

                            #14
                            Re: PopUp Focus - How To?

                            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

                            Comment

                            Working...