Need Help
-
It is possible to use the [CTRL + W] on the code to close the window or browser? If possible can i have a sample code. Thanks and Regards
Try to write a useful subject line. Almost every thread is about someone who needs help, so that doesn't do anything at all to distinguish your thread from other.
vanhawk wrote:
It is possible to use the [CTRL + W] on the code to close the window or browser?
No, you can't feign keypresses from Javascript.
--- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams
-
It is possible to use the [CTRL + W] on the code to close the window or browser? If possible can i have a sample code. Thanks and Regards
yes it is possible. You have to use combination of onkeydown, onkeyup, and onkeypress functions to catch the keys and call window.close() to close the window. You will be calling these function in body tag. onkeydown you will be checking for ctrl key and initialize the flag for it, onkeyup reset the flag for ctrl, onkeypress check the keycode for W and if ctrl key flag is true and it is W then close the window. This is my understanding, but you might have to play with it. I have done it but it was way past and I don't have the code with me right now.
-----
-
yes it is possible. You have to use combination of onkeydown, onkeyup, and onkeypress functions to catch the keys and call window.close() to close the window. You will be calling these function in body tag. onkeydown you will be checking for ctrl key and initialize the flag for it, onkeyup reset the flag for ctrl, onkeypress check the keycode for W and if ctrl key flag is true and it is W then close the window. This is my understanding, but you might have to play with it. I have done it but it was way past and I don't have the code with me right now.
-----