chat window

i want to trigger the chat window after 10 seconds with focus going to x.
what else is needed in the code? please help.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Chat</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.5.2.js'></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/ui-lightness/jquery-ui.css">
<script type='text/javascript'>
$(window).load(function(){
$("#dialog-message").dialog({
    modal: true,
    position: ['center', 'top'],
    width: 250,
   	buttons: {
        "Chat": function() {
            $(this).dialog("close");
        }
    }
});
});
</script>
</head>
<body>
<p>Shopping</p>
<div id="dialog-message" title="Chat"> 
  <div>
    Need help, please chat with our customer service.
  </div>
</div>
</body>
</html>

Open in new window

codelevelAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lenamtlCommented:
Hi,
here is an example that close after a delay
http://jsfiddle.net/j08691/246LG/

Not sure if you really need the focus on close because ten second is very quick...

example for focus on close:
$("#dialog").dialog({
open: function() {
$(this).parents('.ui-dialog').attr('tabindex', -1)[0].focus();
}
});

Open in new window

codelevelAuthor Commented:
i tried the code in my example, but the focus was not going. please check.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Chat</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.5.2.js'></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/ui-lightness/jquery-ui.css">
<script type='text/javascript'>
$(window).load(function(){
$("#dialog-message").dialog({
    modal: true,
    position: ['center', 'top'],
    width: 250,
    open: function() {
		$(this).parents('#dialog-message').attr('tabindex', -1)[0].focus();
	},
   	buttons: {
        "Chat": function() {
            $(this).dialog("close");
        }
    }
});
});
</script>
</head>
<body>
<p>Shopping</p>
<div id="dialog-message" title="Chat"> 
  <div>
    Need help, please chat with our customer service.
  </div>
</div>
</body>
</html>

Open in new window

lenamtlCommented:
Hi just found that you are using a really really old jQuery version...

Are you starting this project? If so you may consider updating jquery to something more recent.

Let me know if you can update the version or not...
codelevelAuthor Commented:
Can change.
lenamtlCommented:
Hi, try this, this should work even on old vesion, edit the number of seconds to your needs

$("#dialog-message").dialog({
    modal: true,
    position: ['center', 'top'],
    width: 250,
   	buttons: {
        "Chat": function() {
            $(this).dialog("close");
          
            setTimeout(function() {
               foo.dialog('close').focus();
            }, 10000);
            
        },
      }  
                                               
});

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.