Jump to content

Recommended Posts

Posted

I need to automatically refresh webpage every 10 seconds, however i want to maintain scroll position. Unfortunately when using meta refresh or javascript location.reload, page returns to top.

Does anyone know how to do this with javascript or asp

James


Posted

if you know the position itll be in you can refresh it to an anchor (page.htm#anchorname) but if the user scrolls, itll just scroll back to the same spot over and over and that prolly wouldnt work

this page seems to have the answer though

http://blogs.x2line.com/al/articles/156.aspx

< html>
< title>< /title>
< head>
< script language="javascript">

// function saves scroll position
function fScroll(val)
{
var hidScroll = document.getElementById('hidScroll');
hidScroll.value = val.scrollTop;
}

// function moves scroll position to saved value
function fScrollMove(what)
{
var hidScroll = document.getElementById('hidScroll');
document.getElementById(what).scrollTop = hidScroll.value;
}
< /script>
< /head>

< body onload="fScrollMove('div_scroll');" onunload="document.forms(0).submit()";>
< form>
< input type="text" id="hidScroll" name="a">< /br>
< div id="div_scroll" onscroll="fScroll(this);"
style="overflow:auto;height:100px;width:100px;">

.. VERY LONG TEXT GOES HERE

< /div>
< /form>
< /body>
< /html>

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...