Category Archives: Internet

IE7 Beta 1 Available

On Wednesday 27th July, the Microsoft IE team announced the public release of IE7 Beta 1.

In April, I commented on IE7 Beta 1 initially being announced and had some serious reservations about it. I felt IE7, in general, was going to be nothing but a patch job and a half arsed attempt at fixing an old and out of date browser. Microsoft have aimed to fix IE many times before, however it has always fallen by the roadside. So, it is easy to see how most people were quite cynical that this time would be any different.

With the initial announcement, the IE team made it clear that the first release of IE7 would be quite limited. Their primary concern was fixing and increasing security, which has plagued all versions of IE. They did mention that they were fixing a couple CSS errors and a couple of general improvements, like PNG support.

Now that it is out, they haven’t disappointed. Dave Shea of Mezzoblue has put together a fairly critical article describing what has and hasn’t been fixed, pointing out that most of the common CSS problems still exist. I’m not quite sure why the tone of that article is so harsh, well I think it is pretty harsh. It shouldn’t come as a surprise to anyone, the IE team said that they weren’t aiming to fix those problems in the first release.

Personally, I think that the developer community should be more happy than sad. The IE team said they were going to release a public beta this summer (ie: the Australian winter) and they have. They have fixed the things they said they would and have committed to adding and fixing plenty more in the future. The wheels of big business often turn slowly, this case is no different. The good news is that they are turning, which is a requirement for them improving the rather dire position that Internet Explorer is in.

Dunstan Orchard & 1976Design

For the past couple of years, I’ve been regularly reading the funny, inspiring and innovative work of Dunstan Orchard. In that time, he has published some fantastic content. Some of my personal favourites are:

Well after a lot of content, plenty of interweb support for his site, skills and flair – it is coming to an end. Dunstan has chosen to say goodbye for the moment. I guess it was driven, in part, by his new job at Apple, The Girlfriend (as Dunstan likes to refer to her) and general lack of time (don’t we know that feeling).

I’ll miss reading your site Dunstan, I wish you and The Girlfriend the best of luck and hope you’ll find the time for your site again soon.

Internet Explorer Popup Blockers

Like most people, I hate spam with a passion. I get spammed with everything from gambling to drugs, which I guess are the things that pay at the moment. The thing I find annoying about it more than anything, is it takes time to clear/purge it from my site and my email.

Anyway, recently the good folk behind Weblog Tools Collection got spammed and posted about it. So now the blogging universe is on a mission to overthrow the dark lords of spam in the search engine universe. Geesh it sounds like something from Star Trek or Star Wars! With all that said, I’m doing my part too.

If you are getting here through a search on Popup Blockers or for Pop-Up Blocker or Pop Up Blocker Internet Explorer, please do not buy from pop-upblocker dot org They are spammers and unethical. ADB Popup Blocker and ANB Pop Up Blocker are from the same company and you should not buy their product. Any SEO people want to help me get this post up on top on the SEs?

Rah, take that you dirty spammers!

Select, Option, Disabled And The JavaScript Solution

As I mentioned recently, there is a bug in Internet Explorer that stops you from disabling options in a select/dropdown element. At the time, I felt this was quite poor so I set about finding a solution. For the impatient among us, you can step straight to implementing it if you want.

Unsuccessful Ideas

In an attempt to save everyone else some time, I’m going to list the different ideas, methods and combinations of, I attempted that were unsuccessful:

  1. Attempt: use the CSS pseudo :hover against the <option> element.
    Problem: Internet Explorer doesn’t support the :hover pseudo class on arbitrary elements.
  2. Attempt: Wrap the contents of the <option> element in an anchor and use the :hover on that instead.
    Problem: The <select> tag is considered a replaced element, which means the tag is replaced with your operating systems equivalent. As a by product, no other HTML element is valid within the <option> tag.
  3. Attempt: Use the JavaScript onmouseover and onmouseout events on the <option> element to make the element appear as though it was disabled.
    Problem: Internet Explorer doesn’t support the onmouseover and onmouseout events against an <option> element.
  4. Attempt: Use the JavaScript onclick event on the <option> element to check if the disabled attribute has been applied, act accordingly if it has been.
    Problem: Again, Internet Explorer doesn’t support the onclick event againt the <option> element.
  5. Attempt: Use the JavaScript onclick event against the <select> element, to again check if an <option> has the disabled attribute in use.
    Problem: Internet Explorer doesn’t support the onclick event against a <select> element.

Successful Ideas

The solution to this problem is comprised of two parts. Firstly, knowing when you make a selection or change the current selection. Secondly, keeping track of the current selection, so you can revert to it in case the user selects a disabled option in the list. If those two things can be achived, then we can emulate the disabled attribute on an option element

Part 1
You can get around not having an onclick event against the option element by using an onchange event against the select. Knowing when you click an option is mandatory, as it lets you know when/if to check that the selected option is disabled. This is taken care of, we can move on.

Part 2
Next up is keeping track of the ‘currently selected’ item. Generally, the first tool in the chest that most people reach for in this case is an onclick event. However, since we’re working with a browser that doesn’t implement those events on the element(s) in question, another solution was needed. The next event that would match what we want to do is onselect, however it isn’t implemented in IE either. Thankfully, the onfocus event is our savior.

How It Works

First thing is making sure that the code only executes on the correct browsers. You could use browser sniffing techniques or proprietary JavaScript functions to isolate IE, however that can be inconsistent. Since we’re targeting IE, it seems more than reasonable to use a conditional comment. In case you are unfamiliar with them, a conditional comment looks like a standard HTML comment to every non-IE browser; however IE interprets them and allows the author very simple conditional testing. We’re going to use this simple testing to include an external JavaScript file.

If the JavaScript does execute, it checks to see if you have any <select> elements in the page. If you do, it iterates through them, attaching an onchange and an onfocus event to each one. At the same time, the disabled option elements (if there are any) are also highlighted with the disabled text colour.

At this point, you have nothing else to do. The onload event and the two functions will do everything for you from this point. The one caveat is if you are manipulating the disabled attributes on the options through the DOM. In which case, you do have to call the emulate function, passing into it a reference the <select> you are manipulating.

The JavaScript

To make this work, an event and two functions are used. They are listed here so you can glance over them:

  1. window.onload = function() {
  2. if (document.getElementsByTagName) {
  3. var s = document.getElementsByTagName("select");
  4. if (s.length > 0) {
  5. window.select_current = new Array();
  6. for (var i=0, select; select = s[i]; i++) {
  7. select.onfocus = function(){ window.select_current[this.id] = this.selectedIndex; }
  8. select.onchange = function(){ restore(this); }
  9. emulate(select);
  10. }
  11. }
  12. }
  13. }

The restore function returns the selected item to its previous selection, if the newly selected item is disabled.

  1. function restore(e) {
  2. if (e.options[e.selectedIndex].disabled) {
  3. e.selectedIndex = window.select_current[e.id];
  4. }
  5. }

The emulate function changes the font colour of all options in a <select> element with the disabled attribute set. The colours used on lines 4 and 7 are CSS2 colour names, which are considered system colours. System colours reflect what your current computer settings are, so they should change with your current desktop theme (at least that is my interpretation of it).

  1. function emulate(e) {
  2. for (var i=0, option; option = e.options[i]; i++) {
  3. if (option.disabled) {
  4. option.style.color = "graytext";
  5. }
  6. else {
  7. option.style.color = "menutext";
  8. }
  9. }
  10. }

Implementing

Using this script is meant to be as simple as possible. All you have to do is download the external JavaScript file. Upload it to your site and place a single conditional comment in your HTML, such as:

  1. <!--[if lt IE 7]>
  2. <script type="text/javascript" src="select-option-disabled-emulation.js"></script>
  3. <![endif]-->

Examples

Following are some simple examples to display what Internet Explorer renders at the moment, through either html/xhtml/quirk/compliant states. There are also two examples of how the script functions as well, simple but they demonstrate it none the less.

Follow Up

After this post being active for over a year now, it continues to draw in consistent traffic from around the internet. Even though this was a proof of concept and not a complete solution, it has saved many people a lot of time. Plenty of people have taken the basic idea I started with and extended it, which I think is fantastic. Recently, a couple of people have sent through comprehensive techniques which are either built on my initial work in some way or inspired by it. These solutions are out perform my simple proof of concept, so they are definitely worth noting for everyone to use:

  • Apptaro created an elegant solution using a DHTML Behaviour file. These behaviour files only execute in Internet Explorer which is a great way isolating it from interfering with other web browsers.
  • Kaleb Walton has implemented a JavaScript object oriented version of my proof of concept. Kaleb’s version implements the fix for a standard dropdown, a listbox and a multi-select listbox.

Both of the above examples are excellent, so you should pick which ever you feel is best going to suit your needs.

Combating Website Spam

Back toward the start of February, I wrote about the implementation and ramifications of the rel=”nofollow” attribute on user submitted content. Shortly afterward, I was prompted to write the rel=”nofollow” follow up entry as well. The idea back then was that website spam, in particular weblog spam, was rife and we (read: search engines) needed an answer. As a *cough*solution*cough*, some bright people thought that if they removed the reward (of PageRank in Google for instance), that the spammers would stop.

I’m here today to tell you that it hasn’t stopped, in fact I’d nearly say that it has increased. On the grander scale of things, I don’t get a lot of spam. A useful by product of that is, it’s also very handy for me to gauge how much spam I’m getting. If I were receiving hundreds or thousands of spam messages daily, I’d be handling them through ‘mass editing’ methods – “select all, delete”. Since I’m not though, I get to see, glance and sometimes even read the spam!

Over the past months, I’ve tried various spam defense mechanisms on the site. Some people have gone to extremes to implement some of the things I mentioned (ie: a ‘set’ of mechanisms that change each time you attempt to post) – so as to require the human factor to make the post. These systems no doubt work very well, however the problem I see with some of them is that they are restricting users from commenting on your site. A friend of mine has a small blog, hosted at Blogger – problem is that her site requires that you are a member before you can post. This single thing alone has stopped me to date from leaving comments – I want to but I just can’t be bothered signing up to leave a comment. I’d consider myself someone that will go to fairly long lengths to get between A and B, but if I won’t sign up for a dummy account on blogger to post – this to me proves that some anti-spam techniques aren’t just stopping the spammers.

One of the anti-spam techniques that I find works very well is keyword detection. If a spammer mentions a certain phrase in their spam, it is flagged that it requires moderation before it will go live. I think one of the primary reasons that this method is so easy to implement and effective, is that the spammers utilise SEO techniques in their spamming. By implementing SEO techniques, I mean that they, for instance use the same word or phrase to help build their keyword importance and visibility. A practical example might be having 100 inbound links to a particular page on your site, but all with different link text versus the same 100 links but all with the same link text. Since we know that they use these SEO techniques, it plays into our favour for simple detection. I’ve got a list of less than 50 words that I use to capture spam and so far they are working out wonderfully.

This isn’t earth shattering news for most but it might remind some people that simplicity is a beautiful thing. I often think we get caught up in overly complex systems to get between A and Z when there is often a shorter simpler path available that we’ve overlooked or discounted previously.