Jump to content

Jquery auto refresh focus


CONFUSIONUK

Recommended Posts

Below I have a script I have quickly whipped up to show you the principles of what I am on about.

Pretty straight forward, #shouts div includes shouts.php with shouts from shoutbox, jquery refreshes the #shouts div with the contents from shout.php every X amount of seconds...

 

All is well and works fine but I am a bit fussy when it comes to the little details, basically you can scroll through the shouts in the div fine while it is refreshing them constantly BUT, would anyone know if it is even possibly to stop the refresh from loosing focus ie when you highlight some text in the div and it refreshes your text will still be highlighted?

 

Any help will be much appreciated  ::)

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Refresh</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
var auto_refresh = setInterval(
function()
{
$('#shouts').load('shouts.php');
}, 1000);
</script>
<style type="text/css">
#shouts { background: #36F; height: 200px; overflow: auto; width: 300px; }
</style>
</head>

<body>
<div id="shouts"><?php include'shouts.php'; ?></div>
</body>
</html>

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.