|
HTML Tip:
Links that Work, Sometimes
by Tom Dahm,
Chief Operations Officer,
NetMechanic, Inc.
Browser incompatibility represents a huge challenge for all webmasters. Incompatibility issues can affect your images, JavaScript functions, style sheets, and page layout. But you may not realize that browser compatibility problems can also affect your links.
But The Links Work - Or Do They?
Have you ever gotten a bad link report from HTML Toolbox and found that the link works just fine in your browser? The problem is usually due to your choice of Web browser. Some links on your site that work fine in Internet Explorer may be broken in Netscape Navigator and other browsers.
This is just one more way that minor errors in the way you write your HTML code can make a big difference in the way your Web page displays on different browsers.
In particular, Internet Explorer often corrects invalid URLs used in your links, allowing them to work correctly. Netscape Navigator and all other browsers don't make these corrections, so visitors get broken links.
All links on your page can be affected:
- Links between Web pages
- Links to images
- Links to external style sheets
- Links to external scripts
|
In fact, these problems can occur anywhere you define a URL. One error repeated many times on an image map can break your site's entire navigation system!
Explorer Fills In The Blanks
How does this happen? Explorer tries to figure out what you meant the HTML code to do - not what you actually coded. According to the official rules of HTML, the link below isn't a legal link because its URL contains a white space, but it's valid in Explorer anyway:
<A HREF="my file.htm">Bad Link!</A>
If you click on this link using Netscape Navigator, the browser asks your Web server for a file named simply "my," not "my file.htm." Since no such file exists on the server, this will generate an error message.
But if you click on this link with Internet Explorer, that browser actually asks the server for a file called "my%20file.htm."
That little "%20" is the key: it's what's known as the "URL encoding" for the space character. That's the official way a URL should refer to a space. Internet Explorer recognizes that "my file.htm" is an illegal URL and changes it automatically. No other browser will make this correction.
Watch For Backslashes
That isn't the only type of URL correction performed by Internet Explorer. Take a look at the HTML code for another link:
<A HREF="http://www.netmechanic.com\news\vol4\no18.htm">Another Bad Link!</A>
This link also contains an illegal URL because it uses a series of backslashes, instead of forward slashes.
If you come from a Windows background, that's an easy mistake to make. After all, backslashes are the way Windows/DOS specifies the path to a particular file on your computer. The Internet grew out of the Unix world and uses forward slashes to specify file paths instead. In fact, whether someone refers to a "\" as a backslash or a forward slash is a good way to tell whether they come from a Windows or Unix background.
Once again, if you click on this link using Internet Explorer, IE will automatically correct the URL, changing all backslash characters into forward slashes.
No other browser will make this correction. Instead the browser will typically display an error message saying "unable to locate the site www.netmechanic.com\news\vol4\no18.htm." In other words, the browser treated the entire URL as the domain name of a Web site. Since no such Web site exists, you get an error message.
Link Checkers Save Time And Effort
Checking the links by hand can be time-consuming - and deceptive. Even though they work fine in Explorer, they really are bad links. The Link Check report included in our HTML Toolbox reports an error for links written using illegal URL syntax. Use it to keep your site accessible to the 17 million people who don't use Explorer!
Does your Web site have links that only work for Internet Explorer? You may want to click here and check your links with HTML Toolbox.
Be careful, though: the free sample of HTML Toolbox will check only the first 25 links on your page. To check all the links in your Web site, sign up for the full version of HTML Toolbox for only $60. That's a small price to pay to keep your visitors happy.
|