window.close()

M

mcnewsxp

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
 
J

Jonathan N. Little

mcnewsxp said:
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!
 
M

mcnewsxp

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>
 
M

mcnewsxp

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.
 
B

Beauregard T. Shagnasty

mcnewsxp said:
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.
 
D

Dylan Parry

mcnewsxp said:
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.
 
M

mcnewsxp

Dylan Parry said:
mcnewsxp said:
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.
 
J

Jonathan N. Little


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...
 
M

mcnewsxp

Jonathan N. Little said:
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. ;^)
 
J

Jonathan N. Little

mcnewsxp said:
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.
 
M

mcnewsxp

Jonathan N. Little said:
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
 
D

dorayme

"Jonathan N. Little said:
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.
 
M

mcnewsxp

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.
 
J

Jonathan N. Little

mcnewsxp said:
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>
 
M

mcnewsxp

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.
 
M

Mayeul

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.
 
M

mcnewsxp

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?
 
D

Dylan Parry

mcnewsxp said:
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.
 
A

Adrienne Boswell

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?
 
J

Jonathan N. Little

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

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top