All pastes #337164 Raw Edit

Untitled

public text v1 · immutable
·published 2007-02-02 16:03 UTC
rendered paste body
<script type="text/JavaScript">         
    ///Attaching a function on window.onload event.
    window.onload = function()
    {
        var strCook = document.cookie; 
        /// This condition will set scroll position of <body>.
        if(strCook.indexOf("!a")!= -1)
        { 
            var intS = strCook.indexOf("!a"); 
            var intE = strCook.indexOf("a!"); 
            var strPos = strCook.substring(intS+2,intE); 
            document.body.scrollTop = strPos; 
        } 
        /// This condition will set scroll position of <div>.
        if(strCook.indexOf("!b")!= -1)
        { 
            var intdS = strCook.indexOf("!b"); 
            var intdE = strCook.indexOf("b!"); 
            var strdPos = strCook.substring(intdS+2,intdE); 
            document.getElementById('div1').scrollTop = strdPos; 
        }
    } ;
    window.onunload = function()
    {
    /// Save Scroll position of page 
        var intY = document.body.scrollTop; 
        document.cookie = "yPos=!a" + intY + "a!"; 
    /// Save Scroll position of <div id="div1>" 
        var divY = document.getElementById('div1').scrollTop; 
        document.cookie = "divPos=!b" + divY + "b!"; 
    } ;
</script>