close webform java script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGF1bA==?=

    close webform java script

    I am looking for a java script to close a web form that I can attatch to a
    button click event. I am using vs2005, c#.
    Thanks
    --
    Paul G
    Software engineer.
  • Gustavo Cantero

    #2
    Re: close webform java script

    Paul:
    The script "window.close() " close the window in the browser. Is this
    that you need?

    Gustavo A. Cantero
    CEO - Scientia® Soluciones Informáticas
    MCP - MCSD - MCTS

    El blog de Scientia® Soluciones Informáticas



    -----Mensaje original-----
    De: Paul [mailto:Paul@dis cussions.micros oft.com]
    Expuesto a las: Martes, 07 de Octubre de 2008 05:46 p.m.
    Expuesto en: microsoft.publi c.dotnet.framew ork.aspnet
    Conversación: close webform java script
    Asunto: close webform java script

    I am looking for a java script to close a web form that I can attatch to a
    button click event. I am using vs2005, c#.
    Thanks
    --
    Paul G
    Software engineer.

    Comment

    • Mark Rae [MVP]

      #3
      Re: close webform java script

      "Gustavo Cantero" <g.cantero@scie ntia.com.arwrot e in message
      news:7A0F0A1B77 EE4A3F932D1D235 D10FF6F@CATALIN A...

      [top-posting corrected]
      >I am looking for a java script to close a web form that I can attatch to
      >a
      >button click event. I am using vs2005, c#.
      >
      The script "window.close() " close the window in the browser. Is this
      that you need?
      That will generate a message asking the user to confirm that they want to
      close the window, and you have omitted the final semi-colon.

      The correct JavaScript is:

      "window.opener= null;window.clo se();"


      --
      Mark Rae
      ASP.NET MVP


      Comment

      • =?Utf-8?B?UGF1bA==?=

        #4
        Re: close webform java script

        Thanks for the responses, do I just attatch this to the onclick event?
        --
        Paul G
        Software engineer.


        "Mark Rae [MVP]" wrote:
        "Gustavo Cantero" <g.cantero@scie ntia.com.arwrot e in message
        news:7A0F0A1B77 EE4A3F932D1D235 D10FF6F@CATALIN A...
        >
        [top-posting corrected]
        >
        I am looking for a java script to close a web form that I can attatch to
        a
        button click event. I am using vs2005, c#.
        The script "window.close() " close the window in the browser. Is this
        that you need?
        >
        That will generate a message asking the user to confirm that they want to
        close the window, and you have omitted the final semi-colon.
        >
        The correct JavaScript is:
        >
        "window.opener= null;window.clo se();"
        >
        >
        --
        Mark Rae
        ASP.NET MVP

        >
        >

        Comment

        • Ben Amada

          #5
          Re: close webform java script

          Mark Rae [MVP] wrote:
          "Gustavo Cantero" <g.cantero@scie ntia.com.arwrot e in message
          news:7A0F0A1B77 EE4A3F932D1D235 D10FF6F@CATALIN A...
          >
          >>I am looking for a java script to close a web form that I can attatch
          >>to a button click event. I am using vs2005, c#.
          >>
          >The script "window.close() " close the window in the browser. Is this
          >that you need?
          >
          That will generate a message asking the user to confirm that they want
          to close the window, and you have omitted the final semi-colon.
          >
          The correct JavaScript is:
          >
          "window.opener= null;window.clo se();"
          That only appears to be the case with IE6.

          In IE7, setting opener to null doesn't appear to make a difference. There
          is a difference between closing a window that was opened by script versus
          closing a window that was not opened by script. You're prompted with a
          confirmation if closing a window that was _not_ opened by JavaScript. If
          the window was opened by JavaScript, you're not prompted with a confirmation
          (it just closes). Setting window.opener to null doesn't change this.

          In Firefox, if you try to close a window that was not opened by JavaScript,
          it doesn't close and you get the message "Warning: Scripts may not close
          windows that were not opened by script." in the error console. If you close
          a window that was opened by JavaScript, you're not prompted with a
          confirmation (it just closes). This is true regardless of setting
          window.opener to null.

          In Safari 3.1, setting opener to null makes no difference. Windows opened
          by script always close without a confirmation, and windows not opened by
          script will not close with window.close().

          Comment

          • bruce barker

            #6
            Re: close webform java script

            setting opener to null was a trick that works due a (minor) security bug
            with ie 6.0 (opener should be read only). no properly coded browser will
            allow javascript to close a main (non popup) window, only windows that
            were opened with javascript (and thus have an opener defined) will
            respond to window.close().

            -- bruce (sqlwork.com)

            Ben Amada wrote:
            Mark Rae [MVP] wrote:
            >
            >"Gustavo Cantero" <g.cantero@scie ntia.com.arwrot e in message
            >news:7A0F0A1B7 7EE4A3F932D1D23 5D10FF6F@CATALI NA...
            >>
            >>>I am looking for a java script to close a web form that I can attatch
            >>>to a button click event. I am using vs2005, c#.
            >>>
            >>The script "window.close() " close the window in the browser. Is this
            >>that you need?
            >>
            >That will generate a message asking the user to confirm that they want
            >to close the window, and you have omitted the final semi-colon.
            >>
            >The correct JavaScript is:
            >>
            >"window.opener =null;window.cl ose();"
            >
            That only appears to be the case with IE6.
            >
            In IE7, setting opener to null doesn't appear to make a difference.
            There is a difference between closing a window that was opened by script
            versus closing a window that was not opened by script. You're prompted
            with a confirmation if closing a window that was _not_ opened by
            JavaScript. If the window was opened by JavaScript, you're not prompted
            with a confirmation (it just closes). Setting window.opener to null
            doesn't change this.
            >
            In Firefox, if you try to close a window that was not opened by
            JavaScript, it doesn't close and you get the message "Warning: Scripts
            may not close windows that were not opened by script." in the error
            console. If you close a window that was opened by JavaScript, you're
            not prompted with a confirmation (it just closes). This is true
            regardless of setting window.opener to null.
            >
            In Safari 3.1, setting opener to null makes no difference. Windows
            opened by script always close without a confirmation, and windows not
            opened by script will not close with window.close().

            Comment

            • Ben Amada

              #7
              Re: close webform java script

              bruce barker wrote:
              setting opener to null was a trick that works due a (minor) security bug
              with ie 6.0 (opener should be read only). no properly coded browser will
              allow javascript to close a main (non popup) window, only windows that
              were opened with javascript (and thus have an opener defined) will
              respond to window.close().
              Aaah ... I wasn't aware of this issue with IE6. Another item on my "go away
              IE6" list :)

              Comment

              Working...