Webdoodles

April 24, 2007

Spam Update

Filed under: CSS, HTML Form — ukmagician @ 8:35 am

The anti form spam measure I outlined in my previous post seems to have worked.

After a day or so I was down from 10+ spam emails a day to only one or two.

Strangely, they were of a similar format (similar gobbldy gook in the submitted fields) to the ones that used to clog up my inbox. Which suggests they were automated?

Anyway, happily they now seem to have tailed off completely.

So all is well until a more advanced spam bot comes along and can beat this anti spam method.

However, there is scope to change the method I described because there is always more than one way to achieve the same result using CSS, for example different methods to hide the fake fields.

April 20, 2007

Using the ALT attribute for Accessibility and Search Engines

Filed under: Search Engine Friendly, Website Accessibility — ukmagician @ 10:41 am

The W3C Accessibility Guidelines identify providing text equivalents for non-text elements in a web page as a top priority for making web pages accessible to all users.

The ALT attribute allows you to do this for images (within the <IMG> tag) and other non-text elements. As well as helping with accessibility, this also helps to make your site more search engine friendly since search engine spiders cannot otherwise glean any information from images.

One thing I tend to do is to write ALT text in a similar way for similar images – for all logos the ALT text begins with “Logo:”, for all photos the ALT text begins with “Photo:” and so on.

You can also add the LONGDESC attribute to provide more detail about a non-text element. The W3C states that the LONGDESC attribute can be used with the <IMG> and <FRAME> tags. (The LONGDESC attribute provides a link to a page providing further information – I’m not sure how well this is supported by different browsers). The ALT attribute can still be included to provide a title for the image.

Check out Free DIY SEO for more information on making pages search engine friendly.

April 10, 2007

Javascript Back Link

Filed under: Javascript, Navigation — ukmagician @ 9:41 am

I’ve recently had need to add on-page links to replicate the ‘back’ button in the browser.

Normally, I avoid using javascript for navigation in this way, but it seems like the best solution in this case. However, I couldn’t find a version of the code which worked consistently accross browsers.

Finally, result number 20 or so in Google (amongst many other pages with others asking about the same problem) turned up this page: www.irt.org/script/911.htm which seems to work well (tested in FF 1.5 and IE 6).

I’ve added the following function to the javascript file:

// go back to previous page function
function goBack() {
history.back();
}

And use the following code in the HTML:

<a href="#" onClick="this.href='javascript:goBack()'" title="Go back to the previous page">&laquo; Back to previous page</a>

Previously, I had tried using onclick="javascript:history.go(-1);" and onclick="history.back();", and a number of variations with the javascript in the href attribute or onclick event or in an external function, but none of them gave consistent results – most didn’t work at all.

If anyone understands enough about javascript to tell me why onClick="this.href='javascript:goBack()'" works, please leave a comment!

Blog at WordPress.com.