Wednesday, October 17, 2007
Accessing properties on the document object is slow in Internet Explorer. I used to use the document object as a place to store globals, ie
function onclick() {
document.clicks +=1;
}

But this is slow in IE. Instead use:

var clicks;
function onclick() {
clicks += 1;
}
Here is a full page that demonstrates this idea. I use onmousemove to simplify doing an action over and over, and you can also FEEL how slow it is by moving your mouse around the page.

And the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Document Object Test</title>

<script type="text/javascript">
var totalObj = new Object();
var flag = false;
function loaded() {
document.onmousemove = useDocument;
}

function useDocument() {
document.total += 5;
}

function useGlobal() {
totalObj.total += 5;
}

function flip() {
if (flag) {
document.onmousemove = useDocument;
document.getElementById('styleType').innerHTML = '&nbsp;document object';

}

else {
document.onmousemove = useGlobal;
document.getElementById('styleType').innerHTML = '&nbsp;global object';
}
flag = !flag;
}

</script>
</head>
<body onload="loaded();">

<a href="#" onclick="flip(); return false;">Click to flip styles</a><span id="styleType"> document</span>

</body>
</html>

Posted By: Chris Burkhardt on October 17, 2007  #    Disclaimer  |  Comments [0]  | 
 Thursday, October 11, 2007
Today I downloaded IE7 and set it to my default browser, leaving Firefox after about 5 years of use. Firefox is still a good browser, but with IE implementing tabbed browsing I don't have to put up with the annoyances of Firefox to get tabs. Here are the 10 main reasons I am switching.

1. Tools-->Options-->Show Passwords-->Show Passwords WTF? I should have stopped using firefox when someone showed me this for the first time.

2. The real last straw was Firefox's support for EV(Extended Verification) certificates. I can't find any solid information if they will be supported in FF3, or even when FF3 is scheduled to come out. I found this post, but this kind of attitude of denouncing a decision after it has been made rather than trying to help the process really bothers me. 

3. Auto update. I don't know why firefox updates in the background and then gives me a crap dialog box to "install now or later" nagging me every time I start it. Did they get bought out by Adobe?

4. Firefox still has memory problems. If I surf for 2-3 hours, opening a lot of tabs, and then trim down to 2-3 base tabs Firefox will still be around 200meg.

5. Buggy CSS. As much as firefox fans crow about how good their CSS is, there are still way to many bugs/inconsistencies.

6. Too many versions. There are too many versions and no clear road map. We don't really need 2.0.3, and all the versions give fan boys a crutch, "Well, have you updated to 2.0.3a? That will fix your problem"

7. Firefox crashes too much. I'm on my computer all day on XP and Server 2003 and programs don't really crash anymore. Sometimes I kill them, but Firefox crashes at least once a month.

8. Too much blame on extensions. Any problem with FF is shoved off to "its probably an extension". Extensions should not be allowed to crash the main program.

9. If I open a new tab and type the url too fast, it does not work. This, surprisingly, is my second biggest reason for leaving Firefox. I used to be able to Ctrl-T, and start typing. Now when I try the cursor is in the address bar blinking, but typing does nothing. I have to lose focus of the address bar and then put it back in.

10. If I have too many tabs open, copy/past breaks. That is, I cannot copy from Firefox to another app. I can copy from notepad to another app, but not Firefox. I cannot reproduce this on purpose, so I don't know for sure it is FF, but I suspect.



Posted By: Chris Burkhardt on October 11, 2007  #    Disclaimer  |  Comments [1]  | 
 Tuesday, October 09, 2007
If you have floated boxes followed by a cleared box, firefox will not honor margin-top on that box.

Here is a page demostrating the firefox bug (pops)

I think Firefox is assuming that the extended margins of float left and right apply to cleared boxes, while the specs do not say or imply that. Here is the relevent section from the spec for the clear property:

left
The top margin of the generated box is increased enough that the top border edge is below the bottom outer edge of any left-floating boxes that resulted from elements earlier in the source document.
right
The top margin of the generated box is increased enough that the top border edge is below the bottom outer edge of any right-floating boxes that resulted from elements earlier in the source document.
both
The generated box is moved below all floating boxes of earlier elements in the source document..
none
No constraint on the box's position with respect to floats.

Here is a baseline html/css sample:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Firefox css bug</title>
</head>
<body>
<div id="container">
<div style="background-color: Orange; width: 100px; height: 35px; float: left">
</div>
<div style="background-color: green; width: 100px; height: 35px; float: left">
</div>
<div style="background-color: black; width: 100px; height: 35px; clear: both; margin-top: 30px;">
</div>
</div>
</body>
</html>


Posted By: Chris Burkhardt on October 9, 2007  #    Disclaimer  |  Comments [0]  | 
 Wednesday, October 03, 2007
I just spent about 4 hours trying to debug this problem.

Here is the setup, a user with a slow connection was not able to view a .wmv on a site. The .wmv was 250mb and he was timing out at 11:34. Different browser, different computer, all that jazz. Our site runs on iis 5 with .NET 2.0 and the file is "hotlinked". That is, we are not using any kind of Response.Write to write to the stream, just linking to it and letting the client stream or download it.

I got a hold of dialup computer and account, and I was able to reproduce the problem, getting the server to send a RST about 15 minutes after starting to download the file. This looked like the .NET  Connection Timout setting, which is set to 900 seconds, or 15 minutes, as a default in iis 5.

However, when I made a new site to test this theory, setting the timeout to 20 seconds did not affect it at all. In fact, in the test site, I was not even able to reproduce the error. Besides, why could the .NET Connection Timeout have anything to do with iis sending the file over the wire?

After a ton of debugging, I found the culprit, wildcard application mapping.





The wildcard application mapping was telling .NET to handle ALL files. Because .NET was handling the file, the 900 second timeout was coming into play. This was a requirement for another part of the site to function, so we could not turn it off. What we ended up doing was making the "media" folder, where the wmv lived, its own application, and removing the mapping from there.

This solution was a lot better than upping the timeout because we didn't not want abandoned connections sitting around for ever.

Posted By: Chris Burkhardt on October 3, 2007  #    Disclaimer  |  Comments [0]  |