Posts tagged ‘ie’

More IE/CSS/div fun

Not being a designer spending all my time getting to know the ins and outs of how floating divs work, it tends to take me a little while to get my head around how to lay out pages using pure CSS. I thought I’d pretty much got how to do 2 and 3 column layouts with CSS and divs, but today I found a new problem which really had me stumped for a while.

Essentially I wanted an ordered list, then within each <li> element a couple of <div>s which I could float to layout how I wanted. Everything was working fine in Firefox, but not in IE(6), the images below show the output given in Firefox and IE:

IE (6):

Firefox:

HTML code which generated the above images.

The items numbered 1-3 show how I want the output to appear, but my first stab at the code resulted in items numbered 4-6. As you can see, in Firefox it appears fine, but in IE the ‘float:left’ is being ignored, making the div containing the text appear below the checkbox. [Aside: you might ask why I'm using divs and floats for something as simple as just some text next to a checkbox, well, this is just my starting point, my final page will be more complicated than this example!]

The only difference between the working and non-working examples is that the div containing text has width property defined (set to 100%) in the working version. I’m not sure why this should be necessary – my example shows that it’s not needed if the wrapper div isn’t part of an ordered list.

My only explanation is that this is another (frustrating) little IE CSS bug – unless anyone can give me another explanation? Alternatively if there are better ways to do what I’m trying to achieve?

IE crashing with MSG

Came back from holiday yesterday (see the pics!) , to find a stack of emails about problems with MSG crashing IE. This is a bit odd as we’ve not updated MSG for a little while, so strange that it just seems to have started occuring. It seems quite an erratic problem, but it does bring the whole browser down – something I find a little odd for a purely javascript application.

I’m really hoping to get this fixed very soon, but haven’t yet found the root cause, I can reliable recreate the issue, so just need to find why it’s happening.

Plus I need to get my presentation for next weeks OpenLearn conference written sometime soon!

Update (29th Oct)… I have now got the problem resolved, though still don’t know the real root cause. I fixed it by going back through the changes I’ve made recently and seeing at what point the error started occuring.
The change which appears to have been causing the error was when I switched from using <a href=”javascript:….”> to using (what I thought was the proper way!) of adding/removing event listeners. The actual problem occured with the call to detach event, although it didn’t fail everytime – it would work for the first few times and then randomly cause the browser to crash. I did notice that the carsh would only happen if I had the MSG client and the referring site (the one with the users presence icon) open at the same time, if only one was open the crash wouldn’t occur.

For info this was the code that was causing problems:

var oldImg = presenceNode.firstChild;
//remove any current listeners
if(oldImg.removeEventListener){ // Mozilla, Netscape, Firefox
oldImg.removeEventListener('click', launchClick, false);
oldImg.removeEventListener('click', readMessageClick, false);
} else { // IE
oldImg.detachEvent('onclick', launchClick);
oldImg.detachEvent('onclick', readMessageClick);
}

So I replaced this with the code below that just alters the location and title of the link (also a bit of adjusting to add the <a> in):

var oldAnchor = presenceNode.firstChild;
var newAnchor = oldAnchor.cloneNode(true);
newAnchor.href = "javascript:readMessageClick();";
newAnchor.title = MSGAPIconf.str_oneMessageUnread;


So, glad to have got it fixed, but would be even better to know why this was really happening at all!

Update Number 2 (1st Nov) – The fix has now been made live on the MSG-OpenLearn servers.

CSS ul & li border differences in IE6 & Firefox

Spent a little while this morning trying to fix a little inconsistency between IE (v6) and Firefox in how the border settings for ul and li elements worked. Here are a couple of screenshots to demonstrate the problem:

IE:

Firefox:

And here’s a snippet of the CSS I was using:

ul.menu {
margin: 0;
padding: 0;
left: 20px;
width: 90%;
border-bottom: solid 1px #d09800;
}

ul.menu li {
display: inline;
margin: 0;
}

ul.menu,
ul.menu li a {
padding: 5px 15px 6px;
}

ul.menu li a {
font-size: 1em;
color: #d09800;
margin: 0;
border: solid 1px ;

}

ul.menu li a:hover {
background: #fdfaf3;
color: black !important;
text-decoration: none;
border: solid 1px #d09800;
}

ul.menu li.current_page_item a,
ul.menu li.current_page_item a:hover {
color: #333 !important;
background: white;
text-decoration: none;
broder: 1px;
border-top: solid 1px #d09800;
border-left: solid 1px #d09800;
border-right: solid 1px #d09800;
border-bottom: solid 1px white;
}

When I changed this snippet to be:

ul.menu {
margin: 9px;
padding-left: 10px;
border-bottom: 1px solid #d09800;
padding-bottom: 6px;
padding-top: 5px;
}

ul.menu li {
display: inline;
margin: 0px;
}

ul.menu li a {
padding: 5px 15px 6px;
border: 1px solid #d09800;
text-decoration: none;
font-size: 1em;
color: #d09800;
margin: 0;
}

ul.menu li a:hover {
background: #fdfaf3;
color: black;
text-decoration: none;
}

ul.menu li.current_page_item a,
ul.menu li.current_page_item a:hover {
border-top: 1px solid #d09800;
border-bottom: 1px solid #fff;
list-style: none;
display: inline;
color: #333;
background: white;
text-decoration: none;
}

Everything worked as I wanted it to! For info the original CSS was taken from the K2 WordPress template which I adapted for the tabbed menu that we wanted for the MSG site.

getElementsByName…

Found that we had a bug where the presences weren’t being updated in IE but they were in Firefox (which I usually use) – tracked the problem down to the differences in how these browsers deal with the document.getElementsByName – I was using the name element on a span tag which Firefox ‘recognises’ but IE doesn’t, for more info on this: http://jszen.blogspot.com/2004/07/whats-in-name.html.

Anyway, turned out to be easy enough to fix by just putting the name on the img tag rather than span.