Creating a Safari Friendly Search
If you’re a mac user like me, then you can appreciate all the subtle nuances Apple adds to its products. One of these is the ability to add a custom search field in Safari. With a simple attribute change, you can transform a regular text field into a Mac-a-fied search box.

Basic text field:
<input type="text" />
Safari-specific search box:
<input type="search" />
Include past search data:
<input type="search" results="5" />
This method degrades gracefully in most modern browsers, but it isn’t valid markup. I’ve remedied this minor problem by using JavaScript to dynamically add these attributes. The following example uses the jQuery library but could also be written to use traditional DOM Scripting.
if($.browser.safari) {
$("#search-box").attr({ type: "search", results: "5" });
}
Even though Safari users are in the minority, they’ll appreciate this improvement to their browsing experience.
It really is a shame that it’s not valid code… seems to me that it would be more semantically correct.
-----
Well it’s not valid because of course it’s a third party extension. The hack is an elegant way of keeping markup valid. But I’m not so sure Safari users will appreciate this. What about privacy?
Next entry: Evolving Design Standards: The Fold
Previous entry: Flash Open-Source Goodness at Levitated.net

Recent Comments
JQuery is cool. I recently combo’d it with shadowbox.js to make a gallery of recent projects. The cycle.js plug-in is also worth looking at for lots of ‘Flash-like’ transitions and animations.
- Website Designer Perth on 'Fun With jQuery's Animate() Function'.
- Website Designer Perth on 'How I'm Using Adobe Bridge'.
- Mindy Wagner on 'How I'm Using Adobe Bridge'.
Subscribe to Comments RSS