The Information Technology Blog brought to you by 4 Ace Technologies

Wednesday, November 18, 2009

9 Most Common IE Bugs and How to Fix Them

Author: Siddharth
Original Article is at: http://net.tutsplus.com/tutorials/html-css-techniques/9-most-common-ie-bugs-and-how-to-fix-them/

1. Centering a Layout

Centering an element is probably something every web developer has to do while creating a layout. The easiest and most versatile way to center an element is to just add margin: auto; to the relevant element. The above method will take care of centering the element irrespective of the resolution and/or browser width. IE 6 in quirks mode however decides to handle this in the most unfortunate way possible: by not handling it at all.

Consider the Following Code:

  1. #container{
  2. border: solid 1px #000;
  3. background: #777;
  4. width: 400px;
  5. height: 160px;
  6. margin: 30px 0 0 30px;
  7. }
  8. #element{
  9. background: #95CFEF;
  10. border: solid 1px #36F;
  11. width: 300px;
  12. height: 100px;
  13. margin: 30px auto;
  14. }

The output you'd expect:

Tutorial Image

But what IE actually gives you:

Tutorial Image

This is mainly due to IE6 in quirks mode and below not recognizing the auto value we set to the margin property. Fortunately, this is easily fixed.

The Fix

The easiest and most reliable way to center content for IE6 and below is to apply text-align: center to the parent element and then apply text-align: left to the element to be centered to make sure the text within it is aligned properly.

  1. #container{
  2. border: solid 1px #000;
  3. background: #777;
  4. width: 400px;
  5. height: 160px;
  6. margin: 30px 0 0 30px;
  7. text-align: center;
  8. }
  9. #element{
  10. background: #95CFEF;
  11. border: solid 1px #36F;
  12. width: 300px;
  13. height: 100px;
  14. margin: 30px 0;
  15. text-align: left;
  16. }

2. Staircase Effect

Almost every web developer uses lists to create his navigation. Usually, you create the container element, create some links inside and then float the anchors in the direction he wants and calls it a day. Usually. IE though decides to make it a lot more complicated. Peruse through the following code:

  1. <ul>
  2. <li><a href="#">a>li>
  3. <li><a href="#">a>li>
  4. <li><a href="#">a>li>
  5. ul>
  1. ul {
  2. list-style: none;
  3. }
  4. ul li a {
  5. display: block;
  6. width: 130px;
  7. height: 30px;
  8. text-align: center;
  9. color: #fff;
  10. float: left;
  11. background: #95CFEF;
  12. border: solid 1px #36F;
  13. margin: 30px 5px;
  14. }

A standard compliant browser renders it like so:

Tutorial Image

And the IE screen shot:

Tutorial Image

Not a particularly pleasing navigation if you ask me. Fortunately, there are 2 fixes you can try.

Fix #1

The easiest way to combat this is to float the li elements themselves instead of the anchor elements. Just add this and you should be done.

  1. ul li {
  2. float: left;
  3. }

Fix #2

The second way is to apply display: inline to the enclosing li element. In addition to fixing this bug, it also fixes the double margin bug mentioned below. Purists may not like placing block elements inside inline elements though.

  1. ul li {
  2. display: inline
  3. }

3. Double Margin on Floated Elements

This bug is probably among the first ones a web developer starting out will run into and is specific to Internet Explorer 6 and below. Triggering it is as simple as floating an element and then applying a margin in the direction it has been floated. And voila! The margin will be doubled in the rendered output. Not really something you'd look forward to while creating a pixel perfect layout.

Consider this code:

  1. #element{
  2. background: #95CFEF;
  3. width: 300px;
  4. height: 100px;
  5. float: left;
  6. margin: 30px 0 0 30px;
  7. border: solid 1px #36F;
  8. }

On standards compliant browsers, this is how it looks:

Tutorial Image

But here is how IE 6 decides to render it:

Tutorial Image

The Fix

The fix for this specific bug is to apply display: inline to the floated element and everything works as it is supposed to. Our previous code now changes to:

  1. #element{
  2. background: #95CFEF;
  3. width: 300px;
  4. height: 100px;
  5. float: left;
  6. margin: 30px 0 0 30px;
  7. border: solid 1px #36F;
  8. display: inline;
  9. }

4. Inability to Have Elements with Small Heights

As part of creating a layout, you may need to create elements with very small heights as custom borders for elements. Usually, you'll just have to add height: XXpx to the style's declarations and you should be done. Or so you thought. Check the page in IE and you'll probably do a double take.

As an example, look at the following code:

  1. #element{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 300px;
  5. height: 2px;
  6. margin: 30px 0;
  7. }

And the output is just as expected: A 2 px element with a 1 px border.

Tutorial Image

And in IE:

Tutorial Image

Fix #1

The cause of this bug is pretty simple: IE simply refuses to size an element smaller than the set font size. Simply setting the font size to 0 lets you have an element as small and short as you like.

  1. #element{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 300px;
  5. height: 2px;
  6. margin: 30px 0;
  7. font-size: 0;
  8. }

Fix #2

The next best way to deal with this bug is to apply overflow: hidden to the element so it collapses to the intended height.

  1. #element{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 300px;
  5. height: 2px;
  6. margin: 30px 0;
  7. overflow: hidden
  8. }

5. Auto Overflow and Relatively Positioned Items

This bug rears its ugly head when in a layout you set the parent container's overflow property to auto and place a relatively positioned item inside it. The relatively positioned item violates its parent element's boundaries and overflows outside. Let me demonstrate. Look the following code:

  1. <div id="element"><div id="anotherelement">div>div>
  1. #element{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 300px;
  5. height: 150px;
  6. margin: 30px 0;
  7. overflow: auto;
  8. }
  9. #anotherelement{
  10. background: #555;
  11. width: 150px;
  12. height: 175px;
  13. position: relative;
  14. margin: 30px;
  15. }

And the expected output:

Tutorial Image

And IE's output:

Tutorial Image

The Fix

The easiest way to fix this annoying bug is to just position the parent element relatively too.

  1. #element{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 300px;
  5. height: 150px;
  6. margin: 30px 0;
  7. overflow: auto;
  8. position: relative;
  9. }

6. Fixing the Broken Box Model

Internet Explorer's misinterpretation of the box model is perhaps its unforgivable mistake. IE 6 in semi-standards compliant mode sidesteps this but this issue can still be triggered by quirks mode.

Two div elements. One with the fix applied and one without. The difference in the width and height is the sum of the paddings applied on each side.

Tutorial Image

The Fix

I am sure the quandary with the box model needs neither explanation nor demonstration so I'll just give you the fix.

The trick is to set the width normally for all standards compliant browsers, target IE5/6 alone and then feed it the corrected width. This is how you'd usually go on about:

  1. #element{
  2. width: 400px;
  3. height: 150px;
  4. padding: 50px;
  5. }

This now changes to:

  1. #element {
  2. width: 400px;
  3. height: 150px;
  4. \height: 250px;
  5. \width: 500px
  6. }

Essentially, you add the padding to the original width and feed it to IE 6. The fix targets IE 6 in quirks mode alone so you need not worry about IE 6 in normal mode messing things up.

7. Setting a Minimum Width and Height

Setting an minimum height to an element is absolutely imperative when trying to convert a beautiful design into a pixel perfect design. Unfortunately, IE completely ignores the min-height property instead taking the height declared as the minimum height.

Fix #1

The fix is a hack created by Dustin Diaz. It utilizes the !important declaration to make it work. The snippet looks like so:

  1. #element {
  2. min-height:150px;
  3. height:auto !important;
  4. height:150px;
  5. }

Fix #2

The second way is to take advantage of the fact that IE can't parse child selectors.

  1. #element {
  2. min-height: 150px;
  3. height: 150px;
  4. }
  5. html>body #element {
  6. height: auto;
  7. }

8. Floated Layout Misbehaving

One of the important concepts of building table-less layouts using CSS is floating elements. In most cases, IE6 handles this with aplomb but in certain cases it fumbles. When faced with unbreakable content or elements whose width exceeds its parent's width, it causes havoc with the layouts. Let me show you.

Consider this piece of code:

  1. <div id="container">
  2. <div id="element">http://net.tutsplus.com/div>
  3. <div id="anotherelement">div>
  4. div>
  1. #element, #anotherelement{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 100px;
  5. height: 150px;
  6. margin: 30px;
  7. padding: 10px;
  8. float: left;
  9. }
  10. #container{
  11. background: #C2DFEF;
  12. border: solid 1px #36F;
  13. width: 365px;
  14. margin: 30px;
  15. padding: 5px;
  16. overflow: auto;
  17. }

The expected output as viewed on a standards compliant browser:

Tutorial Image

In IE:

Tutorial Image

As you can see, the first div expands itself to fit the content which ultimately breaks the layout.

The Fix

There is no elegant fix for this bug. The only way to save the layout is to apply overflow: hidden to the element but at the cost of clipping the unbreakable content. The layout will be saved but the extra content won't.

  1. #element{
  2. background: #C2DFEF;
  3. border: solid 1px #36F;
  4. width: 365px;
  5. margin: 30px;
  6. padding: 5px;
  7. overflow: hidden;
  8. }

9. Space Between List Items

IE 6 adds vertical spacing even none is specified in specific cases. Let's look at the code first.

  1. <ul>
  2. <li><a href="#">Link 1a>li>
  3. <li><a href="#">Link 2a>li>
  4. <li><a href="#">Link 3a>li>
  5. ul>
  1. ul {
  2. margin:0;
  3. padding:0;
  4. list-style:none;
  5. }
  6. li a {
  7. background: #95CFEF;
  8. display: block;
  9. }

What it should look like:

Tutorial Image

What IE gives us:

Tutorial Image

Fortunately, there are a plethora of fixes you could try.

Fix #1

The easiest way out is to just define a width for the anchor tags and voila! everything renders as it should. Declaring a width triggers the element's IE specific hasLayout property. You could instead define a height if you want to.

  1. li a {
  2. background: #95CFEF;
  3. display: block;
  4. width: 200px;
  5. }

Fix #2

The next method is to just float the anchor left and then clearing it.

  1. li a {
  2. background: #95CFEF;
  3. float: left;
  4. clear: left;
  5. }

Fix #3

The third method is to add display: inline to the enclosing li element. This also fixes the double margin bug as noted above.

  1. li {
  2. display: inline;
  3. }

Conclusion

And there you have it: the nine most common IE rendering bugs, and how to squash them. Hopefully this has saved you some blood, sweat and tears while debugging your next creation. I'll be watching the comments section frequently; so chime in here if you are having difficulties implementing the fixes noted here.

Monday, November 9, 2009

Installing PHP on IIS 6 (Windows 2003)

We had a customer who was paying good money for a Dedicated Server of Windows 2003, and had his site hosted. We had to develop a newer version of the site on PHP/MySQL, and then consolidate both sites, the old one and new one. When we came to the stage of Consolidation, we needed a separate PHP enabled server, and that would have costed the customer, so on mutual understanding with customer we had to finally take this challenge of enabling PHP with Windows 2003 server IIS 6.0

I spent lot of time on browsing over the internet and knowing how to install PHP on IIS, and found good solutions, but none were actually working for me. So I hope my solution will be a very brief one, and would help somebody save lot of time.

What I prefer, and did, was as below:
  1. Download Web Developer Suite
  2. Install Web Developer Suite
  3. Open the Web Developer Suite after installation, and click on Disable Startup for Apache. You should see the MySQL and IIS W3 as Running
  4. Then you should be able to run the php files on your IIS wwwroot folder. However, if any error such as "Service Unavailable" or Page not able to be displayed occurs, then check the Application Pool if it is running or stopped. Also make sure you add .php extension from Home Directory, and select the file "php5isapi.dll". Also go to "Web services" and add a new web service as "PHP" and select the file php5isapi.dll from your php directory, and save.
  5. You have PHP installed in few steps, Restart IIS, and you should have it working.
Hope it helps...

Tuesday, November 3, 2009

phplist - Opensource Newsletter Management Script

Newsletter Management

phplist Features

  • phplist is a one-way email announcement delivery system. It is great for newsletters, publicity lists, notifications, and many other uses. (It is different from group mailing list systems like mailman.)
  • The Web Interface lets you write and send messages, and manage phplist over the internet.
  • phplist keeps sending messages from your web server, even after you shut down your computer.
  • 100 000 + subscribers. phplist is designed to manage mailing lists with hundreds of thousands of subscribers. phplist is excellent with smaller lists too!
  • No duplicate messages. No 'forgotten' messages. phplist manages message delivery with a message queue, ensuring that every subscriber gets the email message, and that no subscribers receive two copies, even if they're subscribed to more than one list!
  • Open/View Tracking tells you how many users opened your email message. This provides a minimum statistic, as many email clients with privacy or security policies block images (gmail, thunderbird, and others).
  • Click Tracking tracks links and URLs. Statistics can be viewed by message, URL or subscriber.
  • Multiple Subscribe Pages allow you to choose many different combinations of templates, languages, user attributes and lists.
  • Templates are completely customizable, and make site integration a breeze.
  • Multiple Templates on different subscribe pages can integrate phplist with several different web sites.
  • Subscriber Attributes like 'name', 'country', and other personal information, are completely customizable. You can specify what information you need to get from users when they subscribe.
  • User Specific Content. You can use Subscriber Attributes in message content to make each and every email message personalized with the subscribers name, country, or any other attribute.
  • HTML email messages. Subscribers can be given the choice between text or html email messages. You decide whether subscribers can choose, what the default choice is, and what format a message is sent in: text only, html only, or both!
  • The HTML Editor allows you to edit html messages from phplist using FCKeditor. TinyMCE is also available.
  • Internationalization. phplist is available in English, French, German, Spanish, Portuguese, Traditional Chinese, Dutch, Vietname and Japanese and translation work is in progress for other languages.
  • Easy Install via Fantastico, FTP upload, or SSH.
  • Multiple List Administrators. The super-admin can assign lists to List Managers, who can manage their users and lists. The super-admin user can 'prepare' messages that can be sent by list managers to their lists.
  • Subscriber Preferences. Every email message contains personalized URLs for subscribers to update their preferences or unsubscribe. Subscribers can update their own information and keep your database up to date. Unlike most other mailing list managers, in phplist subscribers can change their email address.
  • The User Management tools are excellent to manage and maintain large databases of subscribers.
  • Bounce Processing keeps your database clean of unused and non-existent email addresses.
  • Advanced Bounce handling let's you teach phplist to distinguish between permanent and temporary message-delivery errors. You can define automated actions on receipt of bounce messages according to matches with your regular expressions.
  • CSV Import and Export. Use CSV and tab delimited files to import your existing list of users or to export the users on the phplist system for use in your in-house database. phplist's database has a 'foreign key' to help keep multiple copies of databases synchronized without duplicating users.
  • Attachments can be uploaded and included in messages for download.
  • Send a Web page. Tell phplist the URL of a web page you want to send to your users, and phplist will fetch it and send it. You can even put subscriber-specific parameters in the URL.
  • RSS feeds can be automatically sent to a mailing list weekly, daily, or monthly.
  • PDF messages can be automatically created and sent as attachments to ensure that your message is seen the way it was designed by all your subscribers, regardless of their email message reader.
  • Batch Processing is useful in shared hosting environments. Set the maximum number of sent messages in a given time period.
  • Throttling can limit the load on your server so it doesn't overload.
  • Domain Throttling limits the number of emails to specific domains to keep on the friendly side of their system administrators.
  • Scheduled Sending let's you tell phplist when the message is to be sent.
  • Repetition. A message can be repeated automatically to send updated dynamic content and attachments.
  • Text from HTML. Text email messages are managed fluently in phplist. phplist will automatically create a text version of an html message. Optionally the message composer can create it manually.
  • PGP signing and encrypting (soon).
    Send your message digitally signed or encrypted, or both.
  • Email to Fax (soon).
    Configure the details of your favourite email 2 fax gateway and phplist will send the HTML version of the message as a PDF attachment to your fax gateway. The fax will include the images in the HTML.
  • Integration with other tools. Several systems exist on the internet that integrate phplist with your favourite CMS or blogging tool. Check out the Documentation for a list.

Download phplist

Version

phplist version 2.10.10 is the latest stable release. It was released on May 5th, 2009.

License

phplist is licensed under the GPL v2. Please make sure that you understand this license before downloading.