Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Scrollbars for Divs in IE not working

Posted on 2008-06-18
3
Medium Priority
?
950 Views
Last Modified: 2013-11-19
I have the following script to create a dropdown Div that provides suggestions for an autosuggest control

AutoSuggestControl.prototype.createDropDown = function () {
      var oThis = this;
     
      //create the layer and assign styles
      this.layer = document.createElement("div");
      this.layer.className = "rbwhite";
      this.layer.style.display = "none";
      this.layer.style.position = "absolute";
      this.layer.style.width = this.textbox.offsetWidth;
//initially the width of the main div is same as that of the textbox control

      this.layer.innerHTML = '<table width="100%" cellspacing="0" cellpadding="0"><tbody>'+
                        '<tr> <td class="rbs_popup_left"/>'+
                        '<td> <div><div id="suggestions'+this.inputName+'" class="rbwhite" ></div> </div></td>'+
                        '<td class="rbs_popup_right"/> </tr>'+
                        '</tbody></table>';
      document.body.appendChild(this.layer);

// <div id="suggestions'+this.inputName+'" class="rbwhite" > is the div that contains all the suggestions. I am having to create so many divs for styling purposes.

};

when displaying the dropdown I do this

// this is the div that contains all suggestions
this.suggDiv = document.getElementById('suggestions'+this.inputName);

//clear all suggestion if there was any
      this.suggDiv.innerHTML = "";
      var i =0;
      
//if there are morre than 25 sugestions show vertical scrollbar
         if((this.endPos - this.startPos) >= 25) {
            this.suggDiv.parentNode.style.height = "150px";
            this.suggDiv.parentNode.style.overflow = "auto";
      }
      else {
            this.suggDiv.parentNode.style.height = "100%";
            this.suggDiv.parentNode.style.overflow ="";
      }
      
      var ht =0;

//create individual suggestion divs and append it the main suggestion div
      for (i=this.startPos; i <=this.endPos; i++) {
            oDiv = document.createElement("div");
            oDiv.id = this.idArr[i];
            oDiv.style.whiteSpace = "nowrap";
            oDiv.innerHTML = "<a href='#'>" + this.objNameArr[i] + "</a>";
            this.suggDiv.appendChild(oDiv);

//calculate the longest suggestion
            if(ht < this.objNameArr[i].length) ht = this.objNameArr[i].length;
      }
      var divWidth = ht+160;
      this.layer.style.width= ( divWidth < 200)? (divWidth+10) +"px" : "200px";
      this.suggDiv.style.width= (divWidth) +"px";

//if the longest suggestion is greater than 200px add horizontal scrollbar
      if(divWidth > 200)
              this.suggDiv.parentNode.style.overflow = "auto";

      this.layer.style.left = this.getLeft() + "px";
      this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
      this.layer.style.display = "block";

This works well infirefox. Shows both horizontal and vertical scrollbars and I am able to scroll them too.
In IE however only the vertical scrollbar shows up and the horizontal scrollbar never shows up. The vertical scrolbars do not scroll. When I click on the veritcal scrollbar  the textbax.onblur event is fired and the the  divs disappear as the onblur function hides this entire suggestions div.

How to make the scrollbars work in IE?  I have tried overflowX =" scroll" and overflow ="scroll" nothing works,
0
Comment
Question by:zmoidin
  • 3
3 Comments
 

Author Comment

by:zmoidin
ID: 21817857
ok I figured out how to display the scrollbars correctly for IE. apparently the Height and width property of the div should be provided implicitly for the scrollbar to work. I was only adding the height for suggDiv.parentNode,  Once I added the the width property for suggDiv.parentNode, the horizontal bars and the vertical bars work fine. Also I had to use the property overflowX= "scroll" and overflowY="scroll" for it to work correctly.

However I still have the problem where, when  I click on either of the scrollbars I am not able to scroll. instead it browser understands it as am onblur event on textbox. How do I make these scrollbars actually scroll?
0
 

Author Comment

by:zmoidin
ID: 21817894
if I disable the onblur event, the scrollbars work fine.

So the problem is that in IE when I click on the scrollbars, other events like textbox.onblur event fires  and causes the suggestions div to hide(on blur is coded to hide suggestions) whereas in firefox this doesnt happen.

Is there a way to recognize the click on scrollbar and prevent the textbox.onblur event not to be called?
0
 

Accepted Solution

by:
zmoidin earned 0 total points
ID: 21817980
This is supposedly a known IE bug
http://support.microsoft.com/kb/818505
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question