Popup Window Detection and Close Button Activation

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

    #1

    Popup Window Detection and Close Button Activation

    Greetings,

    I do not know whether such code exist but no harm asking:

    Is it possible for me to make visible a close button if the active
    window is a popup window or a new window (other than the main window)?

    What I mean is this:

    If the present window is the main window, then the close button should
    not be visible on the page. Otherwise, the close button should be made
    visible and active (i.e. can be clicked to close the window).

    Any help is much appreciated.
  • rf

    #2
    Re: Popup Window Detection and Close Button Activation

    andrewkooi wrote
    [color=blue]
    > Is it possible for me to make visible a close button if the active
    > window is a popup window or a new window (other than the main window)?[/color]

    All windows have a "close" button anyway. That X that the top right.

    --
    Cheers
    Richard.


    Comment

    • ZER0

      #3
      Re: Popup Window Detection and Close Button Activation

      On 31 Aug 2004 01:47:06 -0700, andrewkooi wrote:
      [color=blue]
      > Is it possible for me to make visible a close button if the active
      > window is a popup window or a new window (other than the main window)?[/color]

      Check opener property of the current window.

      for example:

      <script type="text/javascript">
      window.onload=f unction(){
      if (window.opener)
      document.getEle mentById("btnCl ose").style.vis ibility="visibl e";
      }
      </script>

      --
      ZER0://coder.gfxer.web-designer/

      ~ Io non soffro di pazzia, ne godo ogni minuto.
      (I don't suffer from insanity, I enjoy every minute of it)

      on air ~ "Ligabue - Ho Messo Via"

      Comment

      • Mick White

        #4
        Re: Popup Window Detection and Close Button Activation

        rf wrote:
        [color=blue]
        > andrewkooi wrote
        >
        >[color=green]
        >>Is it possible for me to make visible a close button if the active
        >>window is a popup window or a new window (other than the main window)?[/color]
        >
        >
        > All windows have a "close" button anyway. That X that the top right.
        >[/color]
        Or a red circle top left....
        Mac OSX
        Mick

        Comment

        • andrewkooi

          #5
          Re: Popup Window Detection and Close Button Activation

          Greetings,
          [color=blue]
          > <script type="text/javascript">
          > window.onload=f unction(){
          > if (window.opener)
          > document.getEle mentById("btnCl ose").style.vis ibility="visibl e";
          > }
          > </script>[/color]

          This code appeared to work fine in IE6 but does not work in NS7, or
          even the latest versions of Opera and Mozilla. Any ideas how to
          resolve this?

          Thanx.

          Comment

          • ZER0

            #6
            Re: Popup Window Detection and Close Button Activation

            On 1 Sep 2004 05:48:38 -0700, andrewkooi wrote:
            [color=blue]
            > This code appeared to work fine in IE6 but does not work in NS7, or
            > even the latest versions of Opera and Mozilla.[/color]

            This code works also in gecko-based browser (my default browser is not IE
            but Firefox).
            Try this page, for example:

            <html>
            <head>
            <title>Untitled </title>
            <style type="text/css">
            #btnClose{margi n-top:8px;display :block;visibili ty:hidden;}
            </style>
            <script type="text/javascript">
            window.onload=f unction(){
            if (window.opener)
            document.getEle mentById("btnCl ose").style.vis ibility="visibl e";
            }
            </script>
            </head>

            <body>

            <button onclick="window .open(window.lo cation.href)">o pen a popup</button>

            <button id="btnClose" onclick="window .close()">you are in a
            <strong>popup </strong> window.<br />Click this button to close.</button>

            </body>
            </html>

            (tested on FF)

            --
            ZER0://coder.gfxer.web-designer/

            ~ "Rispetto e' Memoria, non Oblio."

            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: Popup Window Detection and Close Button Activation

              andrewkooi wrote:
              [color=blue]
              > Is it possible for me to make visible a close button if the active
              > window is a popup window or a new window (other than the main window)?[/color]

              You asked that a few hours before, and my answer is still the same.
              It is inappropriate to re-post within such a short amount of time
              only because no one replied to date. Especially on Google Groups
              postings take time to be archived, since it is only an archive of
              Usenet postings.


              PointedEars
              --
              All I asked for was a simple rotating chair! Throw me a frickin' bone here!

              Comment

              Working...