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
https://forums.phpfreaks.com/topic/208060-jquery-auto-refresh-focus/
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.