» Forums
» The DHTML Calendar
» General discussion
» Fixed a bug when displaying calendar on IE7
Fixed a bug when displaying calendar on IE7
2007/05/16 03:31
Viewed 6492 times
Replies: 3/7
by Dave

Hello,

There is a bug in the script on IE7. If the page is long enough to scroll and the calendar popup button is down below the main viewable area, when the user scrolls down and clicks on the calendar popup button the calendar will appear at the top of the page (where the element would be if the page doesn't scroll.

I created a small updated script which fixes this issue on IE7 although I haven't tested it on IE6 because I don't have that browser anymore. My guess is that IE7 doesn't recognize the scrollTop, scrollLeft property anymore (or correctly).

Added to line 90 of calendar.js

// ADDED
Calendar.is_ie7 = ( Calendar.is_ie && /msie 7\.0/i.test(navigator.userAgent) );

Added to line 1396 of calendar.js
//ADDED
if (Calendar.is_ie7) {
br.y += window.scrollY;
br.x += window.scrollX;
} else {
br.y += document.body.scrollTop;
br.x += document.body.scrollLeft;
}

Re: Fixed a bug when displaying calendar on IE7
2007/05/16 05:15
Viewed 8672 times
Replies: 0/0
by Dave

just in case anyone has any replies or additions I have subscribed to this thread.

last
Re: Fixed a bug when displaying calendar on IE7
2007/06/15 16:54
Viewed 8011 times
Replies: 1/3

I Fixed the bug on my way, tested on IE7, IE6(Multiple IE), FF, and SAFARI, with those lines :

if (document.body.scrollLeft){br.x += document.body.scrollLeft;}
br.x += window.scrollX;
if (document.body.scrollTop){br.y += document.body.scrollTop;}
br.y += window.scrollY;

and it works.

last
Re[2]: Fixed a bug when displaying calendar on IE7
2007/10/31 12:24
Viewed 7716 times
Replies: 2/2

Dave, did you mean like this ?:
if (Calendar.is_ie7) {
br.y += window.scrollY;
br.x += window.scrollX;
}
else if (Calendar.is_ie) {
br.y += document.body.scrollTop;
br.x += document.body.scrollLeft;
}
else {
br.y += window.scrollY;
br.x += window.scrollX;
}

If I'm dong it right, this is better, except in IE7 when the positioning element is at the bottom of the screen, then the calendar is also, half off the screen. Seems to be ok in IE6 & FF.
For Elyoukey's fix, this seems to occur in all the above browsers.
We are so close now...

last
Re: Fixed a bug when displaying calendar on IE7
2008/09/11 08:34
Viewed 1023 times
Replies: 1/1

Try this - it uses feature detection instead of useragent detection:

Place these two functions at the top of the file - or in a utility.js or whereever they'll be seen by the Calendar object:

getViewportScrollX = function() {
var scrollX = 0;
if( document.documentElement && document.documentElement.scrollLeft ) { //IE standards compliant and W3C
scrollX = document.documentElement.scrollLeft;
}
else if( document.body && document.body.scrollLeft ) { // IE 6 not standards compliant
scrollX = document.body.scrollLeft;
}
else if( window.pageXOffset ) { // older browsers
scrollX = window.pageXOffset;
}
else if( window.scrollX ) { // Gecko and KHTML/Webkit browsers I think...
scrollX = window.scrollX;
}
return scrollX;
};

getViewportScrollY = function() {
var scrollY = 0;
if( document.documentElement && document.documentElement.scrollTop ) {
scrollY = document.documentElement.scrollTop;
}
else if( document.body && document.body.scrollTop ) {
scrollY = document.body.scrollTop;
}
else if( window.pageYOffset ) {
scrollY = window.pageYOffset;
}
else if( window.scrollY ) {
scrollY = window.scrollY;
}
return scrollY;
};

Replace this section starting at line 1392:

if (Calendar.is_ie) { //Ugh!
br.y += document.body.scrollTop;
br.x += document.body.scrollLeft;
} else {
br.y += window.scrollY;
br.x += window.scrollX;
}

with calls to the above functions:

br.x += getViewPortScrollX();
br.y += getViewPortScrollY();

See here for more than you wanted to know about viewports:


last
Re[2]: Fixed a bug when displaying calendar on IE7
2008/09/11 08:53
Viewed 1743 times
Replies: 0/0

Oops.

First, put the two utility functions with the other utility functions and name them Calendar.getViewportScrollX and Calendar.getViewportScrollY.

Second, capitali[z|s]ation is important.

Replace the two lines setting br.x and br.y with the following:

br.x += Calendar.getViewportScrollX();
br.y += Calendar.getViewportScrollY();

Hopefully this should all now just work.

Now all you need to do is grep through Calendar.js for document.body.ScrollTop and ScrollLeft and make everything use these two new utility functions instead.

last
Google