RobG a écrit :
> Ross wrote:
>
>> I have been using the following script to return a scrollbar to the
>> position it was in before the data was posted. It works in ie but not
>> in firefox.
>>
You snipped important chuncks of code from the OP. Here it is:
{
> <script type="text/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.getElementById("menu_holder_inside").scro llTop = strPos;
> }
> }
> function SetDivPosition(){
> var intY = document.getElementById("menu_holder_inside").scro llTop;
> // document.title = intY;
> document.cookie = "yPos=!~" + intY + "~!";
> }
>
>
> </script>
>
> and on the div
>
> <div id="menu_holder_inside" onscroll="SetDivPosition()">
}
His function name is SetDivPosition. His function name is not
SetPagePosition nor SetWindowPosition or something like that.
>
> This link will explain your problem with 'onscroll':
>
> <URL:http://www.quirksmode.org/js/events_compinfo.html>
>
> Onscroll is a method of the window object, it is not a W3C standard
DOM 3 Events interface compliant, scroll event for element:
"scroll
A document view or an element has been scrolled. The scroll occured
before the dispatch of this event type."
http://www.w3.org/TR/2003/NOTE-DOM-L...l#event-scroll
and
> belongs to DOM Level 0 (i.e. inherited from pre-W3C browsers).
>
MSIE 6, Mozilla 1.x, Firefox 1.x, NS 7.x and a bunch of other browsers
do support the scroll event for scrollable elements like a <div>.
> <URL:http://www.mozilla.org/docs/dom/domref/dom_window_ref72.html#1018974>
>
How about testing this file then?:
http://www.mozilla.org/docs/dom/domr...p.html#Example
>
>
> This link deals with the issue with scrollTop:
>
> <URL:http://www.quirksmode.org/viewport/compatibility.html>
>
> All other browsers use pageYOffset,
pageYOffset is a property of the window object (NS 4+, Mozilla 1.x,
Firefox 1.x, Opera 6+, etc.)
pageYOffset is not a property of the scrollable elements like a <div>.
IE 6 uses
> document.documentElement.scrollTop (in strict mode), for all other IEs
> and 6 in quirksmode use document.body.scrollTop.
>
That's for a document scroll-view. What about a div? That is what the OP
asked..., no?
> You need to feature test (a cross-browser function is provided at the
> link to determine how much the page has scrolled - search for scrollTop
> or pageYOffset).
>
> [...]
>
>
http://developer.mozilla.org/en/docs...lTop#scrollTop
http://www.gtalbot.org/BugzillaSecti...roperties.html
The OP is right regarding Opera 7+. Opera does not support registering a
scroll event listener to a scrollable element. I.e.:
ElementReference.addEventListener("scroll", functionName, false);
is not supported for Opera 7+. But DOM 3 Events compliant browsers
support the scroll event for elements.
http://www.w3.org/TR/2003/NOTE-DOM-L...l#event-scroll
And pretty much all modern browsers support MSIE's DHTML object model.
Gérard
--
remove blah to email me