Skip to main content

Bug Tracker

Side navigation

#2895 closed bug (invalid)

Opened May 18, 2008 03:33PM UTC

Closed October 12, 2009 11:30PM UTC

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@gmail.com
Blocked by: Blocking:
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 (1)
Change History (3)

Changed May 18, 2008 03:39PM UTC by Aray comment:1

Replying to [ticket:2895 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

Changed May 19, 2008 03:25AM UTC by Aray comment:2

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.

To solve this problem, find line "var y = e.pageY || 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.

Changed October 12, 2009 11:30PM UTC by dmethvin comment:3

resolution: → invalid
status: newclosed

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 .