...

View Full Version : How to simulate a KEY PRESS event



FichasdeGalalit
01-12-2012, 12:42 AM
Hi,

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.

FG

Philip M
01-12-2012, 08: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.

FichasdeGalalit
01-12-2012, 10:52 AM
Hi,

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

FG

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

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