Maintain scroll position on div when return to page

Maintain scroll position on div when return to page

I have a div in the center of my webpage that contains a table the scrolls horizontally, the table is built in jquery and you simply scroll left to right.

The column titles are the links, so that when a category ios click you go to a new page that contains all the documents in that column but htis time you can click to view them.

What Im trying to do is then when they click to return to the page, I woudl like the scroll bar to return to the position it was in.


Start of output from source code

<div class="wrapper1">
<div class="container-inner">
<div class="table">
<table class='gridtable' cellpadding='0' cellspacing='1'>
<tr>
<th><span style="font-weight:bold">1. </span><a href="view.php?corp_ID=6&amp;category=54" title="Memorandum and Articles - Click to view all documents">Memorandum and Articles </a></th> <th><span style="font-weight:bold">2. </span><a href="view.php?corp_ID=6&amp;category=56" title="Patents - Click to view all documents">Patents </a></th> <th><span style="font-weight:bold">3. </span><a href="view.php?corp_ID=6&amp;category=57" title="Shareholders &amp

And this is the code that creates the above, some of it anyway

<div class="container-outer" style="margin-top:-1px;">
<div class="container-inner">
<div class="table">

<table class='gridtable' cellpadding='0' cellspacing='1'>
<?php
    echo '<tr>'."\r";
    $number=1;
    $catcnt = count($Categories);    
    foreach($Categories as $CatID => $Category): 
    
        $Category = str_replace("& ","&amp; ",$Category);
        if(!isset($_GET['Cat']) || isset($_GET['Cat']) && $_GET['Cat'] == $CatID):
            echo '<th id="'. $number .'"><span style="font-weight:bold">'. $number .'. </span><a href="view.php?corp_ID=' . $CORPid . '&amp;category=' . $CatID . '" title="' . $Category . ' - Click to view all documents">' . $Category . ' </a></th>'."\r";
        endif;
        $number++;
    endforeach;
    
    echo '</tr>'."\r";

I have tried using the code below, but with no success.

<script language="javascript"> 
window.onload = function(){
var strCook = document.cookie;
if(strCook.indexOf("!~")!=0) {
var intS = strCook.indexOf("!~");
var intE = strCook.indexOf("~!");
var strPos = strCook.substring(intS+2,intE);
document.getElementByClassName("gridtable").scrollTop = strPos;
}
}
function SetDivPosition(){
var intX = document.getElementByClassName("gridtable").scrollTop;
document.title = intX;
document.cookie = "xPos=!~" + intX + "~!";
}
</script>





































































    • Topic Participants

    • info