C
crazychrisy54
Hi there
I have used some javascript very similar to other examples on the net
in order ro remember where my overflow div scroll position is after a
refresh.
This code works fine with firefox but with IE it flickers too much
because the scroll first goes to the top left part of the image and
then scrolls back down to the users previous scroll position. Does
anyone have any suggestions how to fix this problem or am I stuck!?
Any help would be much appreciated
The code I used was adapted from Eric Pascarello's "remember a div
scroll position" and is as follows:
Javascript:
window.onload = function(){
var strCook = document.cookie;
if(strCook.indexOf("!~")!=0){
var intStart = strCook.indexOf("!~");
var intEnd = strCook.indexOf("~!");
var strVerticalScrollValue = strCook.substring(intStart
+2,intEnd);
document.getElementById("pmDIV").scrollTop =
strVerticalScrollValue;
}
if(strCook.indexOf("!#")!=0){
var intStart = strCook.indexOf("!#");
var intEnd = strCook.indexOf("#!");
var strHorizontalScrollValue = strCook.substring(intStart
+2,intEnd);
document.getElementById("pmDIV").scrollLeft =
strHorizontalScrollValue;
}}
function SetDivPosition(){
var intY = document.getElementById("pmDIV").scrollTop;
var intX =
document.getElementById("pmDIV").scrollLeft;
document.cookie = "yPos=!~" + intY + "~!";
document.cookie = "xPos=!#" + intX + "#!";
}
HTML page:
<div id="pmDIV" onscroll="SetDivPosition()" style="overflow: auto;"
//Includes a ever growing image
</div>
Thanks again for your time
Chris
I have used some javascript very similar to other examples on the net
in order ro remember where my overflow div scroll position is after a
refresh.
This code works fine with firefox but with IE it flickers too much
because the scroll first goes to the top left part of the image and
then scrolls back down to the users previous scroll position. Does
anyone have any suggestions how to fix this problem or am I stuck!?
Any help would be much appreciated
The code I used was adapted from Eric Pascarello's "remember a div
scroll position" and is as follows:
Javascript:
window.onload = function(){
var strCook = document.cookie;
if(strCook.indexOf("!~")!=0){
var intStart = strCook.indexOf("!~");
var intEnd = strCook.indexOf("~!");
var strVerticalScrollValue = strCook.substring(intStart
+2,intEnd);
document.getElementById("pmDIV").scrollTop =
strVerticalScrollValue;
}
if(strCook.indexOf("!#")!=0){
var intStart = strCook.indexOf("!#");
var intEnd = strCook.indexOf("#!");
var strHorizontalScrollValue = strCook.substring(intStart
+2,intEnd);
document.getElementById("pmDIV").scrollLeft =
strHorizontalScrollValue;
}}
function SetDivPosition(){
var intY = document.getElementById("pmDIV").scrollTop;
var intX =
document.getElementById("pmDIV").scrollLeft;
document.cookie = "yPos=!~" + intY + "~!";
document.cookie = "xPos=!#" + intX + "#!";
}
HTML page:
<div id="pmDIV" onscroll="SetDivPosition()" style="overflow: auto;"
//Includes a ever growing image
</div>
Thanks again for your time
Chris