window.open(...) does not work

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wladimir Borsov

    #1

    window.open(...) does not work

    Inside a html page (more precicesly inside a JSP page) I defined a button.
    When the user clicks this button a second browser window should pop up und load the passed
    URL. I coded

    <img src="mybutton.g if" onclick='window .open("http://mydomain.com", "Mytitle);' >

    However when I click on the button (under Win2000 + IE5.5) no window pops up.

    Why?

    Are there other ways to get a new browser window?

    Wladi

  • Dylan Parry

    #2
    Re: window.open(... ) does not work

    Spake Wladimir Borsov unto thee:
    [color=blue]
    > Are there other ways to get a new browser window?[/color]

    The way I do it, if I really have to do it, is to use a link like:

    <a href="page.html "
    onclick="window .open('page.htm l','','width=40 0,height=400'); return
    false;">link text</a>

    That way you get a new window of whatever size you suggest if the
    user agent supports it, but the page still opens if it doesn't. Of course,
    there are millions of reasons why one shouldn't use new windows, but I am
    not going to go into them.

    --
    Dylan Parry
    http://webpageworkshop.co.uk - FREE Web tutorials and references

    Comment

    • Randy Webb

      #3
      Re: window.open(... ) does not work

      Dylan Parry wrote:
      [color=blue]
      > Spake Wladimir Borsov unto thee:
      >
      >[color=green]
      >>Are there other ways to get a new browser window?[/color]
      >
      >
      > The way I do it, if I really have to do it, is to use a link like:
      >
      > <a href="page.html "
      > onclick="window .open('page.htm l','','width=40 0,height=400'); return
      > false;">link text</a>[/color]

      <a href="somewhere .html"
      onclick="window .open(this.href ,this.target,'. ....');return false">
      link text</a>

      Whenever I do something like that, I usually use a function and pass the
      parameters though:

      <a href="somewhere .html" target="_someWi ndow"
      onclick="myFunc tion(this.href, this.target);re turn false">blah blah
      </a>

      Makes maintenance easier.




      --
      Randy
      comp.lang.javas cript FAQ - http://jibbering.com/faq

      Comment

      • Toby Inkster

        #4
        Re: window.open(... ) does not work

        Wladimir Borsov wrote:
        [color=blue]
        > <img src="mybutton.g if" onclick='window .open("http://mydomain.com", "Mytitle);' >[/color]

        You're missing a quote mark. There are better ways to do what you're doing
        though:

        <a href="http://example.net/" target="Mytitle "
        onclick="window .open(this.href ,this.target); return false;">
        <img src="mybutton.g if" alt="Go to example.net"></a>

        Though popups are, of course, evil.

        --
        Toby A Inkster BSc (Hons) ARCS
        Contact Me ~ http://tobyinkster.co.uk/contact

        Comment

        • Harlan Messinger

          #5
          Re: window.open(... ) does not work

          wladimirb@gmx.n et (Wladimir Borsov) wrote:
          [color=blue]
          >Inside a html page (more precicesly inside a JSP page) I defined a button.[/color]

          That's not really any more precisely from the point of view of the
          browser, which has no knowledge about or interest in how the HTML was
          generated.
          [color=blue]
          >When the user clicks this button a second browser window should pop up und load the passed
          >URL. I coded
          >
          ><img src="mybutton.g if" onclick='window .open("http://mydomain.com", "Mytitle);' >
          >
          >However when I click on the button (under Win2000 + IE5.5) no window pops up.[/color]

          For future reference, this isn't an HTML question, and there was no
          need to post it to the HTML groups, but in any event, are you *sure*
          you checked that all your quotation marks are paired correctly? I see
          one that isn't closed.



          --
          Harlan Messinger
          Remove the first dot from my e-mail address.
          Veuillez ôter le premier point de mon adresse de courriel.

          Comment

          • Richard Cornford

            #6
            Re: window.open(... ) does not work

            Dylan Parry wrote:
            <snip>[color=blue]
            > The way I do it, if I really have to do it, is to use a link like:
            >
            > <a href="page.html "
            > onclick="window .open('page.htm l','','width=40 0,height=400'); return
            > false;">link text</a>
            >
            > That way you get a new window of whatever size you suggest if the
            > user agent supports it, but the page still opens if it doesn't.[/color]
            <snip>

            That isn't necessarily true. If the pop-up blocking is being done by,
            for example, Opera or Mozilla the call to window open does not error, it
            just returns null. The - return false - then cancels the navigation and
            the user gets nothing. Similarly, if the pop-up blocking is being done
            by a content inserting proxy that replaces the - window.open - function
            with a non error-producing dummy then again the - return false - cancels
            the navigation and the user gets nothing.

            It would be nice to be able to return a value from the onclick handler
            that related to the success of the - window.open - call, but no
            comprehensive test for window opening success or failure within the
            calling function has been devised. On the whole I think the subject line
            says it all; " window.open(... ) does not work".

            Richard.


            Comment

            • Rob Martin

              #7
              Re: window.open(... ) does not work


              "Wladimir Borsov" <wladimirb@gmx. net> wrote in message
              news:chnthj$plt $04$1@news.t-online.com...[color=blue]
              > Inside a html page (more precicesly inside a JSP page) I defined a button.[/color]
              [1][color=blue]
              > When the user clicks this button a second browser window should pop up und[/color]
              load the passed[color=blue]
              > URL. I coded
              >
              > <img src="mybutton.g if" onclick='window .open("http://mydomain.com",[/color]
              "Mytitle);' >[color=blue]
              >
              > However when I click on the button (under Win2000 + IE5.5) no window pops[/color]
              up.[color=blue]
              >
              > Why? [2]
              >
              > Are there other ways to get a new browser window? [3]
              >
              > Wladi
              >[/color]

              Hello Wladi

              [1] I was looking for a button, but no - you've defined a graphic/image on
              the page, not a button. Pedantic arent I?!

              [2] Without going any further on whether this is valid or should work or
              whatever - purely a first-look the code syntax - shouldn't there be an end
              speechmark after Mytitle (as you have started an opening speechmark)?

              [3] You'd best search the previous threads on this newsgroup; you'll see how
              much people hate that being forced on them.

              Group: dont want to hijack Wladi's thread (but is probably relevant to his
              question [3]) I totally agree with all what's been said in the past, dont
              like suddenly being in a new window and having to manage it, but what are
              thoughts on entering a web "applicatio n" ie interactive application not
              static pages. An example go to www.amp.com.au and click on "Login" - how
              would what happens there be better? Stay in the same window and keep links
              within the 'application' part back to the 'launching static page' part?
              (which sounds ok to me). Same for internet banking
              (www.commbank.com.au/netbank and click 'start netbank', similar stuff.

              Cheers
              Rob


              Comment

              • Randy Webb

                #8
                Re: window.open(... ) does not work

                Rob Martin wrote:
                [color=blue]
                > "Wladimir Borsov" <wladimirb@gmx. net> wrote in message
                > news:chnthj$plt $04$1@news.t-online.com...
                >[color=green]
                >>Inside a html page (more precicesly inside a JSP page) I defined a button.[/color]
                >
                > [1]
                >[color=green]
                >>When the user clicks this button a second browser window should pop up und[/color]
                >
                > load the passed
                >[color=green]
                >>URL. I coded
                >>
                >><img src="mybutton.g if" onclick='window .open("http://mydomain.com",[/color]
                >
                > "Mytitle);' >
                >[color=green]
                >>However when I click on the button (under Win2000 + IE5.5) no window pops[/color]
                >
                > up.
                >[color=green]
                >>Why? [2]
                >>
                >>Are there other ways to get a new browser window? [3]
                >>
                >>Wladi
                >>[/color]
                >
                >
                > Hello Wladi
                >
                > [1] I was looking for a button, but no - you've defined a graphic/image on
                > the page, not a button. Pedantic arent I?!
                >
                > [2] Without going any further on whether this is valid or should work or
                > whatever - purely a first-look the code syntax - shouldn't there be an end
                > speechmark after Mytitle (as you have started an opening speechmark)?
                >
                > [3] You'd best search the previous threads on this newsgroup; you'll see how
                > much people hate that being forced on them.
                >
                > Group: dont want to hijack Wladi's thread (but is probably relevant to his
                > question [3]) I totally agree with all what's been said in the past, dont
                > like suddenly being in a new window and having to manage it, but what are
                > thoughts on entering a web "applicatio n" ie interactive application not
                > static pages. An example go to www.amp.com.au and click on "Login" - how
                > would what happens there be better? Stay in the same window and keep links
                > within the 'application' part back to the 'launching static page' part?[/color]

                Yes. Instead of opening a new window, simply navigate to

                And have that navigate back to where you want it to go.
                [color=blue]
                > (which sounds ok to me). Same for internet banking
                > (www.commbank.com.au/netbank and click 'start netbank', similar stuff.[/color]

                That one could navigate straight to:

                And then go from there.

                Typically, if a site thinks it *requires* a popup, its an indication of
                lack of knowledge on the part of the web-masters.

                --
                Randy
                comp.lang.javas cript FAQ - http://jibbering.com/faq

                Comment

                • Neal

                  #9
                  Re: window.open(... ) does not work

                  On Wed, 8 Sep 2004 23:28:20 +0200, Wladimir Borsov <wladimirb@gmx. net>
                  wrote:
                  [color=blue]
                  > Inside a html page (more precicesly inside a JSP page) I defined a
                  > button.
                  > When the user clicks this button a second browser window should pop up
                  > und load the passed
                  > URL. I coded
                  >
                  > <img src="mybutton.g if" onclick='window .open("http://mydomain.com",
                  > "Mytitle);' >
                  >
                  > However when I click on the button (under Win2000 + IE5.5) no window
                  > pops up.
                  >
                  > Why?[/color]

                  Because there is justice in the world.

                  Comment

                  • Mark Tranchant

                    #10
                    Re: window.open(... ) does not work

                    Wladimir Borsov wrote:
                    [color=blue]
                    > <img src="mybutton.g if" onclick='window .open("http://mydomain.com", "Mytitle);' >
                    >
                    > However when I click on the button (under Win2000 + IE5.5) no window pops up.
                    >
                    > Why?[/color]

                    Missing quote after Mytitle, perhaps?
                    [color=blue]
                    > Are there other ways to get a new browser window?[/color]

                    Yes. Let the user do it when *they* want to.


                    --
                    Mark.
                    Lichfield Cathedral Chorus, formerly Lichfield Special Choir: a choir of around 100 singers based in Lichfield Cathedral

                    Comment

                    • jmm-list-gn

                      #11
                      Re: window.open(... ) does not work

                      Wladimir Borsov wrote:[color=blue]
                      >
                      > <img src="mybutton.g if" onclick='window .open("http://mydomain.com", "Mytitle);' >
                      > However when I click on the button (under Win2000 + IE5.5) no window pops up.
                      > Why?
                      >[/color]
                      (This is not a javascript ng.)
                      You are missing a trailing double quote for Mytitle.
                      [color=blue]
                      > Are there other ways to get a new browser window?
                      >[/color]
                      <a href="http://mydomain.com" target="_blank" >foo</a>

                      --
                      jmm dash list (at) sohnen-moe (dot) com
                      (Remove .AXSPAMGN for email)

                      Comment

                      • Andrew Thompson

                        #12
                        Re: window.open(... ) does not work

                        On Thu, 09 Sep 2004 22:49:22 -0700, jmm-list-gn wrote:
                        [color=blue]
                        > (This is not a javascript ng.)[/color]

                        I take you mean 'this is not a JS issue'?
                        [color=blue]
                        > <a href="http://mydomain.com" target="_blank" >foo</a>[/color]

                        ( ..given your reference to a link.
                        Good idea, BTW )

                        --
                        Andrew Thompson
                        http://www.PhySci.org/ Open-source software suite
                        http://www.PhySci.org/codes/ Web & IT Help
                        http://www.1point1C.org/ Science & Technology

                        Comment

                        • Michael Winter

                          #13
                          [OT] Re: window.open(... ) does not work

                          On Fri, 10 Sep 2004 06:17:58 GMT, Andrew Thompson <SeeMySites@www .invalid>
                          wrote:
                          [color=blue]
                          > On Thu, 09 Sep 2004 22:49:22 -0700, jmm-list-gn wrote:
                          >[color=green]
                          >> (This is not a javascript ng.)[/color][/color]
                          <[color=blue]
                          > I take you mean 'this is not a JS issue'?[/color]

                          It was originally posted to a.html, ciawh, and clj, with follow-ups set to
                          clj, so both statements are correct.

                          Mike

                          --
                          Michael Winter
                          Replace ".invalid" with ".uk" to reply by e-mail.

                          Comment

                          • Andrew Thompson

                            #14
                            Re: [OT] Re: window.open(... ) does not work

                            On Fri, 10 Sep 2004 07:50:33 GMT, Michael Winter wrote:
                            [color=blue]
                            > On Fri, 10 Sep 2004 06:17:58 GMT, Andrew Thompson wrote:
                            >[color=green]
                            >> On Thu, 09 Sep 2004 22:49:22 -0700, jmm-list-gn wrote:
                            >>[color=darkred]
                            >>> (This is not a javascript ng.)[/color][/color]
                            > <[color=green]
                            >> I take you mean 'this is not a JS issue'?[/color]
                            >
                            > It was originally posted to a.html, ciawh, and clj, with follow-ups set to
                            > clj, so both statements are correct.[/color]

                            I comprehend now. Thanks for clarifying.

                            --
                            Andrew Thompson
                            http://www.PhySci.org/ Open-source software suite
                            http://www.PhySci.org/codes/ Web & IT Help
                            http://www.1point1C.org/ Science & Technology

                            Comment

                            • jmm-list-gn

                              #15
                              Re: window.open(... ) does not work

                              Andrew Thompson wrote:[color=blue]
                              > On Thu, 09 Sep 2004 22:49:22 -0700, jmm-list-gn wrote:
                              >[color=green]
                              >> (This is not a javascript ng.)[/color]
                              >
                              > I take you mean 'this is not a JS issue'?
                              >[/color]
                              Oops. I did not notice it was cross-posted.[color=blue]
                              >[color=green]
                              >><a href="http://mydomain.com" target="_blank" >foo</a>[/color]
                              >
                              > ( ..given your reference to a link. Good idea, BTW )
                              >[/color]
                              Thanks.

                              --
                              jmm dash list (at) sohnen-moe (dot) com
                              (Remove .AXSPAMGN for email)

                              Comment

                              Working...