window.close()

Discussion in 'HTML' started by mcnewsxp, Nov 19, 2010.

  1. mcnewsxp

    mcnewsxp Guest

    when i set the onclick method of my button to "javascript:window.close()"
    the cancel button fires, but my form's action method fires and opens the
    page in the action method (bipassing my validation script - but that's
    another problem) anyway.
    what's the way to make this work right?

    note: if this isn't enough detail please don't ask for URL or feel you need
    to comment. you've either worked this one out before or not.

    peace & tia,
    mcnewsxp
    mcnewsxp, Nov 19, 2010
    #1
    1. Advertising

  2. mcnewsxp wrote:
    > note: if this isn't enough detail please don't ask for URL or feel you need
    > to comment. you've either worked this one out before or not.


    It isn't. Good luck with that!

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Nov 19, 2010
    #2
    1. Advertising

  3. mcnewsxp

    mcnewsxp Guest

    i'll try to make it as simple as possible.
    when you click the "Log Off" buttom a a dialog prompts the user to Close the
    window or Cancel. if they cancel the form's action fires instead of
    cancelling. this is probably what is supposed to happen HTML-wise, but i
    want it to simply close the dialog and return the the same form.
    i am certain this is a common issue to those who have been coding HTML for a
    while. it's new to me.
    here's the markup:

    <FORM NAME="theform" Action="SomeForm.htm" METHOD="POST"
    ENCTYPE="application/x-www-form-urlencoded" onKeyDown="return
    cancelEnter()">

    <other HTML stuff...>

    <input type="SUBMIT" name="Submit2" value="Enter Data" onClick="return
    validate()" style="width:9em;">
    <input type="SUBMIT" name="Submit" value="Log Off"onClick="window.close();"
    style="width:9em;">
    </form>
    mcnewsxp, Nov 19, 2010
    #3
  4. mcnewsxp

    mcnewsxp Guest

    i guess i should mention that that page contains hidden values that are
    posted to the next page so any javascript would probably have to be aware of
    that.

    it is intersting to note that you can ask very detailed programming
    questions using other languages and never be asked for a link to your app.
    mcnewsxp, Nov 19, 2010
    #4
  5. mcnewsxp wrote:

    > i guess i should mention that that page contains hidden values that
    > are posted to the next page so any javascript would probably have to
    > be aware of that.


    Hopefully, this is just a fun web site and none of those "hidden" values
    are important. (They are only hidden from a newbie who doesn't know how
    to View Source.)

    > it is intersting to note that you can ask very detailed programming
    > questions using other languages and never be asked for a link to your
    > app.


    ...but you probably post code or code snippets, eh? Same thing.

    --
    -bts
    -Four wheels carry the body; two wheels move the soul
    Beauregard T. Shagnasty, Nov 19, 2010
    #5
  6. mcnewsxp

    Dylan Parry Guest

    "mcnewsxp" <> wrote:
    > when i set the onclick method of my button to
    > "javascript:window.close()"
    > the cancel button fires, but my form's action method fires and opens
    > the
    > page in the action method

    […]
    > note: if this isn't enough detail please don't ask for URL or feel you
    > need
    > to comment. you've either worked this one out before or not.


    return false;

    Note: if this isn't enough detail please don't ask for a URL or feel you
    need to ask fir further details. You've either come across this one out
    before or not.

    --
    Dylan Parry
    Dylan Parry, Nov 20, 2010
    #6
  7. mcnewsxp

    mcnewsxp Guest

    "Dylan Parry" <> wrote in message
    news:-september.org...
    > "mcnewsxp" <> wrote:
    >> when i set the onclick method of my button to
    >> "javascript:window.close()"
    >> the cancel button fires, but my form's action method fires and opens
    >> the
    >> page in the action method

    > [.]
    >> note: if this isn't enough detail please don't ask for URL or feel you
    >> need
    >> to comment. you've either worked this one out before or not.

    >
    > return false;
    >
    > Note: if this isn't enough detail please don't ask for a URL or feel you
    > need to ask fir further details. You've either come across this one out
    > before or not.
    >
    > --


    sweet.
    mcnewsxp, Nov 20, 2010
    #7
  8. mcnewsxp wrote:
    > "Dylan Parry"<> wrote in message
    > news:-september.org...
    >> "mcnewsxp"<> wrote:


    >
    > sweet.


    Dylan is correct. There could be countless reasons why you are having
    problems which your little fragments just do not provide enough detail
    to diagnose. It is like calling up your mechanic and saying "my car will
    not start" and then expect a solution from him.

    BTW before you do it, posting ALL your markup is not equivalent to
    posting a URL from a web server...

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Nov 20, 2010
    #8
  9. mcnewsxp

    mcnewsxp Guest

    "Jonathan N. Little" <> wrote in message
    news:ic8q1c$mmc$-september.org...
    > mcnewsxp wrote:
    >> "Dylan Parry"<> wrote in message
    >> news:-september.org...
    >>> "mcnewsxp"<> wrote:

    >
    >>
    >> sweet.

    >
    > Dylan is correct. There could be countless reasons why you are having
    > problems which your little fragments just do not provide enough detail to
    > diagnose. It is like calling up your mechanic and saying "my car will not
    > start" and then expect a solution from him.
    >
    > BTW before you do it, posting ALL your markup is not equivalent to posting
    > a URL from a web server...
    >
    > --


    unfortuneately the websites i work on are not public. they require logging
    in with UID and PW. our development sites are internal and require using
    citrix or other remote desktop or actually being on site.
    also, i think i described what i needd in a simple enough way that dylan
    parry was able to answer my question, tho he wasn't able to resist giving me
    a pinch of grief. ;^)
    mcnewsxp, Nov 21, 2010
    #9
  10. mcnewsxp wrote:
    > "Jonathan N. Little"<> wrote in message
    > news:ic8q1c$mmc$-september.org...
    >> mcnewsxp wrote:
    >>> "Dylan Parry"<> wrote in message
    >>> news:-september.org...
    >>>> "mcnewsxp"<> wrote:

    >>
    >>>
    >>> sweet.

    >>
    >> Dylan is correct. There could be countless reasons why you are having
    >> problems which your little fragments just do not provide enough detail to
    >> diagnose. It is like calling up your mechanic and saying "my car will not
    >> start" and then expect a solution from him.
    >>
    >> BTW before you do it, posting ALL your markup is not equivalent to posting
    >> a URL from a web server...
    >>
    >> --

    >
    > unfortuneately the websites i work on are not public. they require logging
    > in with UID and PW. our development sites are internal and require using
    > citrix or other remote desktop or actually being on site.
    > also, i think i described what i needd in a simple enough way that dylan
    > parry was able to answer my question, tho he wasn't able to resist giving me
    > a pinch of grief. ;^)
    >
    >


    I find it amazing that folks that cry for help with problem they admit
    they *do not know the cause*, yet are so confident in their ability it
    isolate the *exact* bit of code which contains the problem.

    I will offer a tip knowing full well it will be ignored: If your project
    is on a private|passworded|intranet|top-secret-spy site and you want
    assistance in debugging. Do not post code fragments. Find a public
    server (there are freebies out there) to post "sanitized" examples that
    exhibit the same problem as you are witnessing with your "inaccessible"
    site.


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Nov 21, 2010
    #10
  11. mcnewsxp

    mcnewsxp Guest

    "Jonathan N. Little" <> wrote in message
    news:icbau8$dmm$-september.org...
    > mcnewsxp wrote:
    >> "Jonathan N. Little"<> wrote in message
    >> news:ic8q1c$mmc$-september.org...
    >>> mcnewsxp wrote:
    >>>> "Dylan Parry"<> wrote in message
    >>>> news:-september.org...
    >>>>> "mcnewsxp"<> wrote:
    >>>
    >>>>
    >>>> sweet.
    >>>
    >>> Dylan is correct. There could be countless reasons why you are having
    >>> problems which your little fragments just do not provide enough detail
    >>> to
    >>> diagnose. It is like calling up your mechanic and saying "my car will
    >>> not
    >>> start" and then expect a solution from him.
    >>>
    >>> BTW before you do it, posting ALL your markup is not equivalent to
    >>> posting
    >>> a URL from a web server...
    >>>
    >>> --

    >>
    >> unfortuneately the websites i work on are not public. they require
    >> logging
    >> in with UID and PW. our development sites are internal and require using
    >> citrix or other remote desktop or actually being on site.
    >> also, i think i described what i needd in a simple enough way that dylan
    >> parry was able to answer my question, tho he wasn't able to resist giving
    >> me
    >> a pinch of grief. ;^)
    >>
    >>

    >
    > I find it amazing that folks that cry for help with problem they admit
    > they *do not know the cause*, yet are so confident in their ability it
    > isolate the *exact* bit of code which contains the problem.
    >
    > I will offer a tip knowing full well it will be ignored: If your project
    > is on a private|passworded|intranet|top-secret-spy site and you want
    > assistance in debugging. Do not post code fragments. Find a public server
    > (there are freebies out there) to post "sanitized" examples that exhibit
    > the same problem as you are witnessing with your "inaccessible" site.
    >
    >


    yea, but i am certain that i did have a bug. i think what i was
    experiencing is what is supposed to happen when you have an onclick method
    for your button and a POST action for the form. both events fire. i
    haven't tried adding the return false bit yet, i knew that someone must've
    experienced this behavior and knew what to do about it. that's all.
    for the future - can you suggest a place i can post code for you all to see?
    best,
    mike
    mcnewsxp, Nov 21, 2010
    #11
  12. mcnewsxp

    dorayme Guest

    In article <icbau8$dmm$-september.org>,
    "Jonathan N. Little" <> wrote:

    > I will offer a tip knowing full well it will be ignored: If your project
    > is on a private|passworded|intranet|top-secret-spy site and you want
    > assistance in debugging. Do not post code fragments. Find a public
    > server (there are freebies out there) to post "sanitized" examples that
    > exhibit the same problem as you are witnessing with your "inaccessible"
    > site.


    And in the process, you can often spot what fixes it.

    --
    dorayme
    dorayme, Nov 21, 2010
    #12
  13. mcnewsxp

    mcnewsxp Guest

    On Nov 21, 12:50 pm, "mcnewsxp" <> wrote:
    > "Jonathan N. Little" <> wrote in messagenews:icbau8$dmm$-september.org...
    >
    >
    >
    > > mcnewsxp wrote:
    > >> "Jonathan N. Little"<>  wrote in message
    > >>news:ic8q1c$mmc$-september.org...
    > >>> mcnewsxp wrote:
    > >>>> "Dylan Parry"<>   wrote in message
    > >>>>news:-september.org...
    > >>>>> "mcnewsxp"<>   wrote:

    >
    > >>>> sweet.

    >
    > >>> Dylan is correct. There could be countless reasons why you are having
    > >>> problems which your little fragments just do not provide enough detail
    > >>> to
    > >>> diagnose. It is like calling up your mechanic and saying "my car will
    > >>> not
    > >>> start" and then expect a solution from him.

    >
    > >>> BTW before you do it, posting ALL your markup is not equivalent to
    > >>> posting
    > >>> a URL from a web server...

    >
    > >>> --

    >
    > >> unfortuneately the websites i work on are not public.  they require
    > >> logging
    > >> in with UID and PW.  our development sites are internal and require using
    > >> citrix or other remote desktop or actually being on site.
    > >> also, i think i described what i needd in a simple enough way that dylan
    > >> parry was able to answer my question, tho he wasn't able to resist giving
    > >> me
    > >> a pinch of grief.   ;^)

    >
    > > I find it amazing that folks that cry for help with problem they admit
    > > they *do not know the cause*, yet are so confident in their ability it
    > > isolate the *exact* bit of code which contains the problem.

    >
    > > I will offer a tip knowing full well it will be ignored: If your project
    > > is on a private|passworded|intranet|top-secret-spy site and you want
    > > assistance in debugging.  Do not post code fragments. Find a public server
    > > (there are freebies out there) to post "sanitized" examples that exhibit
    > > the same problem as you are witnessing with your "inaccessible" site.

    >
    > yea, but i am certain that i did have a bug.  i think what i was
    > experiencing is what is supposed to happen when you have an onclick method
    > for your button and a POST action for the form.  both events fire.  i
    > haven't tried adding the return false bit yet, i knew that someone must've
    > experienced this behavior and knew what to do about it.  that's all.
    > for the future - can you suggest a place i can post code for you all to see?
    > best,
    > mike


    certain that i did NOT have a bug (dang fumble fingers never proof
    read). what i described is the way it works and what i needed was a
    work around - not a bug fix. so stating that you either have
    encountered this or not is not being flippant.
    mcnewsxp, Nov 22, 2010
    #13
  14. mcnewsxp wrote:
    > On Nov 21, 12:50 pm, "mcnewsxp"<> wrote:
    >> "Jonathan N. Little"<> wrote in messagenews:icbau8$dmm$-september.org...
    >>
    >>
    >>
    >>> mcnewsxp wrote:
    >>>> "Jonathan N. Little"<> wrote in message
    >>>> news:ic8q1c$mmc$-september.org...
    >>>>> mcnewsxp wrote:



    >>> I will offer a tip knowing full well it will be ignored: If your project
    >>> is on a private|passworded|intranet|top-secret-spy site and you want
    >>> assistance in debugging. Do not post code fragments. Find a public server
    >>> (there are freebies out there) to post "sanitized" examples that exhibit
    >>> the same problem as you are witnessing with your "inaccessible" site.

    >>
    >> yea, but i am certain that i did have a bug. i think what i was
    >> experiencing is what is supposed to happen when you have an onclick method
    >> for your button and a POST action for the form. both events fire. i
    >> haven't tried adding the return false bit yet, i knew that someone must've
    >> experienced this behavior and knew what to do about it. that's all.
    >> for the future - can you suggest a place i can post code for you all to see?
    >> best,
    >> mike

    >
    > certain that i did NOT have a bug (dang fumble fingers never proof
    > read). what i described is the way it works and what i needed was a
    > work around - not a bug fix. so stating that you either have
    > encountered this or not is not being flippant.



    Hmmm you are certain you have a bug, your are certain you do not have a
    bug. Well at least we know you are "certain".

    Here is why I was flippant, sure I have seen the behavior you describe.
    The problem is it is vague. There is nearly a countless number of
    reasons why your are not trapping an event, without actually "seeing" an
    example any "solution" would be a WAG. Event bubbling or capture, which
    browsers, how are you trapping the event, what is the DOM structure that
    the event traverses...

    So again, <flippant purpose="illustrate my point">"my car won't start so
    tell me what is wrong with provided info..."</flippant>


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Nov 22, 2010
    #14
  15. mcnewsxp

    mcnewsxp Guest

    On Nov 22, 9:27 am, "Jonathan N. Little" <> wrote:
    > mcnewsxp wrote:
    > > On Nov 21, 12:50 pm, "mcnewsxp"<>  wrote:
    > >> "Jonathan N. Little"<>  wrote in messagenews:icbau8$dmm$-september.org...

    >
    > >>> mcnewsxp wrote:
    > >>>> "Jonathan N. Little"<>    wrote in message
    > >>>>news:ic8q1c$mmc$-september.org...
    > >>>>> mcnewsxp wrote:
    > >>> I will offer a tip knowing full well it will be ignored: If your project
    > >>> is on a private|passworded|intranet|top-secret-spy site and you want
    > >>> assistance in debugging.  Do not post code fragments. Find a public server
    > >>> (there are freebies out there) to post "sanitized" examples that exhibit
    > >>> the same problem as you are witnessing with your "inaccessible" site.

    >
    > >> yea, but i am certain that i did have a bug.  i think what i was
    > >> experiencing is what is supposed to happen when you have an onclick method
    > >> for your button and a POST action for the form.  both events fire.  i
    > >> haven't tried adding the return false bit yet, i knew that someone must've
    > >> experienced this behavior and knew what to do about it.  that's all.
    > >> for the future - can you suggest a place i can post code for you all to see?
    > >> best,
    > >> mike

    >
    > > certain that i did NOT have a bug (dang fumble fingers never proof
    > > read).  what i described is the way it works and what i needed was a
    > > work around - not a bug fix.  so stating that you either have
    > > encountered this or not is not being flippant.

    >
    > Hmmm you are certain you have a bug, your are certain you do not have a
    > bug. Well at least we know you are "certain".
    >
    > Here is why I was flippant, sure I have seen the behavior you describe.
    > The problem is it is vague. There is nearly a countless number of
    > reasons why your are not trapping an event, without actually "seeing" an
    > example any "solution" would be a WAG. Event bubbling or capture, which
    > browsers, how are you trapping the event, what is the DOM structure that
    > the event traverses...
    >
    > So again, <flippant purpose="illustrate my point">"my car won't start so
    > tell me what is wrong with provided info..."</flippant>
    >
    > --


    yes, but a form that has an action method and a button that has an
    onclick method that closes the window surely must be a common thing on
    an HTML page. the onclick fires then the form's action method fires.
    how many variations of that could there be? none? adding return
    false; solved my problem - without having to view the URL.
    so there was no bug, but i was ignorant about a particular behavior
    and now i am not. so i tried to frame my question with enough info to
    get the help i needed therefore i don't think your car analogy is apt.
    mcnewsxp, Nov 22, 2010
    #15
  16. mcnewsxp

    Mayeul Guest

    On 22/11/2010 15:51, mcnewsxp wrote:
    > yes, but a form that has an action method and a button that has an
    > onclick method that closes the window surely must be a common thing on
    > an HTML page. the onclick fires then the form's action method fires.
    > how many variations of that could there be? none?


    No, zero is what you get if you divide an int N by the number of variations.

    --
    Mayeul
    Mayeul, Nov 22, 2010
    #16
  17. mcnewsxp

    mcnewsxp Guest

    On Nov 19, 12:40 pm, "mcnewsxp" <> wrote:
    > when i set the onclick method of my button to "javascript:window.close()"
    > the cancel button fires, but my form's action method fires and opens the
    > page in the action method (bipassing my validation script - but that's
    > another problem) anyway.
    > what's the way to make this work right?
    >
    > note: if this isn't enough detail please don't ask for URL or feel you need
    > to comment.  you've either worked this one out before or not.
    >
    > peace & tia,
    > mcnewsxp


    of course then there's firefox....
    something to do with window.close won't close unless window.open is
    used?
    mcnewsxp, Nov 22, 2010
    #17
  18. mcnewsxp

    Dylan Parry Guest

    mcnewsxp <> wrote:
    > of course then there's firefox....
    > something to do with window.close won't close unless window.open is
    > used?


    Most browsers won't allow you to close a window with JavaScript unless
    it was opened by a script to begin with, and they're not supposed to
    either.

    --
    Dylan Parry
    Dylan Parry, Nov 22, 2010
    #18
  19. Gazing into my crystal ball I observed "mcnewsxp"
    <> writing in
    news:icb4ko$pvq$-september.org:

    >
    > "Jonathan N. Little" <> wrote in message
    > news:ic8q1c$mmc$-september.org...
    >> mcnewsxp wrote:
    >>> "Dylan Parry"<> wrote in message
    >>> news:-sep
    >>> tember.org...
    >>>> "mcnewsxp"<> wrote:

    >>
    >>>
    >>> sweet.

    >>
    >> Dylan is correct. There could be countless reasons why you are having
    >> problems which your little fragments just do not provide enough
    >> detail to diagnose. It is like calling up your mechanic and saying
    >> "my car will not start" and then expect a solution from him.
    >>
    >> BTW before you do it, posting ALL your markup is not equivalent to
    >> posting a URL from a web server...
    >>
    >> --

    >
    > unfortuneately the websites i work on are not public. they require
    > logging in with UID and PW. our development sites are internal and
    > require using citrix or other remote desktop or actually being on
    > site. also, i think i described what i needd in a simple enough way
    > that dylan parry was able to answer my question, tho he wasn't able to
    > resist giving me a pinch of grief. ;^)
    >
    >


    I'm sorry. This is going to sound rude, but I am on my second 7&7, so
    here it goes.

    Please try to write in an acceptable manner. Use correct grammer, use
    correct punctuation, check your spelling.

    You will be surprised at how effective this is when trying to get a
    useful response from others. It's a matter of respect.

    Be careful, also, to correctly spell a person's name, especially when
    that person was "able to answer my question". Again, it's a matter of
    respect. How would you feel if I referred to you as mdacousticgitar?

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne Boswell, Nov 23, 2010
    #19
  20. mcnewsxp wrote:

    > the onclick fires then the form's action method fires.
    > how many variations of that could there be?


    <snip>

    > so i tried to frame my question with enough info to
    > get the help i needed therefore i don't think your car analogy is apt.



    Obviously more than you understand. Which event model are you using?
    Which browsers have the problem? How was the window first opened. How is
    is being closed? The code? With a button? Do you mean a <button> element
    or a <input type="submit">? How are you trapping the event? How did you
    attach the JavaScript, hard-coded or via addEventListener & attachEvent?
    On which element and on which event?

    So yes, my car analogy is most apt.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Nov 23, 2010
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    6
    Views:
    8,795
    sateeshranga
    Aug 7, 2008
  2. Iñaki Baz Castillo
    Replies:
    7
    Views:
    820
    Iñaki Baz Castillo
    Jan 12, 2010
  3. Walter Beierdonck

    Self.close() window without the dialog close?Yes/NO

    Walter Beierdonck, Apr 29, 2004, in forum: Javascript
    Replies:
    1
    Views:
    334
    Grant Wagner
    Apr 30, 2004
  4. Replies:
    3
    Views:
    390
    Chung Leong
    Jan 16, 2005
  5. Shang Wenbin

    close current window using window.close()

    Shang Wenbin, Sep 1, 2005, in forum: Javascript
    Replies:
    10
    Views:
    351
    Gérard Talbot
    Sep 2, 2005
Loading...

Share This Page