View Full Version : How to simulate a KEY PRESS event

01-11-2012, 11:42 PM

Hi, I want to simulate user KEY PRESS (not mouse clicking) automatically on a screen every time that a pop up window (script error message) is opened on the screen OR detecting when an an iframe gets focus.

My goal: Automatically closes the pop up window.

If anybody know the exact code please post it.


Philip M
01-12-2012, 07:52 AM
Not possible - for security reasons.

You can use setTimeout() to close a popup window after a pre-determined interval. But you cannot simulate a user key-press or mouse click

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

01-12-2012, 09:52 AM

It is would be very useful. I was thinking in setTimeout(), because what I need it to close the pop up window after an interval in seconds after it open


Philip M
01-12-2012, 12:38 PM
<script type="text/javascript">
var count = 0;
var tim;
function checktime() {
count ++;
if (count==6) { // 6 seconds
tim = setTimeout(checktime,1000);

Note that for security reasons the close method closes only windows opened by JavaScript using the open method. If you attempt to close any other window, a confirm message is displayed, asking the user to choose whether the window is to be closed or not.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum