help to close a popup after time out

help to close a popup after time out

Could someone point me any jquery function or plugin to control popups?

I need to close a login form (popup) if the user forget it opened (after timeout without user activity)

That is what I tried: (javascript only)

  1. var popup , last_history = 0 ;

  2. function open_my_popup(url) {
  3.    popup = window.open(url, 'my_popup', '');
  4.    setTimeout("clock()", 5000);
  5. }

  6. function clock(){
  7.   if( popup.history.length; > last_history ){
  8.      last_history = popup.history.length;
  9.      setTimeout("clock()", 10000);
  10.   } else popup.close();
  11. }

  12. open_my_popup( "http://jquery.com" );



But it let me get the error "permission denied to read window.history.lenght"

Is there any jQuery alternative?