Ticket #2895 (closed bug: invalid)
function coord(el,prop) in JQuerySpinBtn.js not work properly in IE
| Reported by: | Aray | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.2.4 |
| Component: | plugin | Version: | 1.2.3 |
| Keywords: | spin button | Cc: | jeresig@… |
| Blocking: | Blocked by: |
Description
The plugin Spin Button is greate, It is very usefull to me. Thank you for your greate work.
But there were a little problem in JQuerySpinBtn.js, wich I download from http://www.softwareunity.com/sandbox/jqueryspinbtn/JQuerySpinBtn.js.
the function coord(el,prop) not work properly in IE if document.body's padding or margin is not ZERO.
Following is the offcial release of code
function coord(el,prop) {
var c = el[prop], b = document.body;
while ((el = el.offsetParent) && (el != b)) {
if (!$.browser.msie (el.currentStyle.position != 'relative')) c += el[prop];
}
return c;
}
Maybe it should be change to like following:
function coord(el,prop) {
var c = el[prop], b = document.body;
while ((el = el.offsetParent) /*&& (el != b)*/) {
if (!$.browser.msie (el.currentStyle.position != 'relative')) c += el[prop];
} if(el == b)
break;
return c;
}
The attachment SpinButton.zip contain two demon to show the problem, their files are all the same, except JQuerySpinBtn.js
Attachments
Change History
comment:1 in reply to: ↑ description Changed 5 years ago by Aray
Replying to Aray:
The plugin Spin Button is greate, It is very usefull to me. Thank you for your greate work.
But there were a little problem in JQuerySpinBtn.js, wich I download from http://www.softwareunity.com/sandbox/jqueryspinbtn/JQuerySpinBtn.js.
the function coord(el,prop) not work properly in IE if document.body's padding or margin is not ZERO.
Following is the offcial release of code
function coord(el,prop) {
var c = el[prop], b = document.body;
while ((el = el.offsetParent) && (el != b)) {
if (!$.browser.msie (el.currentStyle.position != 'relative')) c += el[prop];
}
return c;
}
Maybe it should be change to like following:
function coord(el,prop) {
var c = el[prop], b = document.body;
while ((el = el.offsetParent) /*&& (el != b)*/) {
if (!$.browser.msie (el.currentStyle.position != 'relative')) c += el[prop];
} if(el == b)
break;
return c;
}
I am so sorry that I have made a mistake, to fix the problem, the correct code should be as following.
function coord(el,prop) {
var c = el[prop], b = document.body;
while ((el = el.offsetParent) /*&& (el != b)*/) {
if (!$.browser.msie (el.currentStyle.position != 'relative')) c += el[prop];
if(el == b)
break;
}
return c;
}
The attachment SpinButton.zip contain two demon to show the problem, their files are all the same, except JQuerySpinBtn.js
comment:2 Changed 5 years ago by Aray
I found another problem when using IE. if the IE window have a scroll bar, and the scroll bar are note in Top or in Left position. It will not work properly
The reason is that, In IE, the Event.y is the distance of document top to mouse point, this distance is NOT including the scroll bar position. so does the Event.x.
| e.y;" in JQuerySpinBtn.js, add following code below this line |
if($.browser.msie) {
x += document.documentElement.scrollLeft;
y += document.documentElement.scrollTop;
}
I don't have enough knowledge of compatibility of JavaScript between IE,Firefox, blabla. The code may make some change.
comment:4 Changed 4 years ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
This is not a jQuery core bug. Please report plugin bugs to the plugin's author, or ask on the jQuery forums. jQuery UI bugs should be reported on the UI bug tracker, http://dev.jqueryui.com .
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

