Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7906 (closed defect: untested)

Opened 1 year ago

Last modified 5 months ago

Position.Page Bug in Netscape Versions <8

Reported by: MyCo Assigned to: MyCo
Priority: normal Milestone: 2.x
Component: Prototype Version: edge
Severity: normal Keywords:
Cc:

Description

Position.Page doesn't work correctly in Netscape up to version 7. The return values for are too low, when the page is scrolled. The Position.Page function has at the end this:

element = forElement;
do {
  if (!window.opera || element.tagName=='BODY') {
    valueT -= element.scrollTop  || 0;
    valueL -= element.scrollLeft || 0;
  }
} while (element = element.parentNode);

If you remove that part it works. I've tested it with: IE6, IE7, Firefox 1.5, Firefox 2, Opera 9, Netscape 7.1, Netscape 8.1, Konqueror

I don't know why this part of code is there, but even if it is usefull for some exotic browsers. It should have been written like this:

if (!window.opera || element.tagName=='BODY') {
  element = forElement;
  do {
    valueT -= element.scrollTop  || 0;
    valueL -= element.scrollLeft || 0;
  } while (element = element.parentNode);
} 

Change History

03/25/07 01:29:01 changed by MyCo

  • owner changed from sam to MyCo.

03/25/07 01:38:03 changed by MyCo

Sorry, I'm wrong, the problem is not in Position.Page. It is in Position.clone

This:

var p = Position.page(source);

should be:

var p = Position.cumulativeOffset(source);

May be it is still wrong, but both of this temporary fixes work for the problem I've got. It's a simple Position cloning of a relative source object to an absolute target object. eg. like the autocompleter from script.aculo.us does

03/25/07 03:35:19 changed by MyCo

Well... It's in Position.Page. I've backtracked the problem and as I said in the first posting, it is this part:

element = forElement;
do {
  if (!window.opera || element.tagName=='BODY') {
    valueT -= element.scrollTop  || 0;
    valueL -= element.scrollLeft || 0;
  }
} while (element = element.parentNode);

Netscape7 returns some weird values for scrollTop, I don't know the reason for this, but I've found a good solution:

if (window.pageYOffset){
  valueT -= window.pageYOffset;
  valueL -= window.pageXOffset;
}else{
  element = forElement;
  do {
    if (!window.opera || element.tagName=='BODY') {
      valueT -= element.scrollTop  || 0;
      valueL -= element.scrollLeft || 0;
    }
  } while (element = element.parentNode);
}

Sorry for the confusing posts... It took a while to understand this functions :-)

01/28/08 16:40:26 changed by kangax

  • status changed from new to closed.
  • resolution set to untested.

I'm closing this as untested (and since it's been 10 month). If you find that the problem is still there (using latest version) feel free to reopen this ticket.