Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8796395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:36:46+00:00 2026-06-13T23:36:46+00:00

Possible Duplicate: Browser detection versus feature detection I have been reading about feature detection

  • 0

Possible Duplicate:
Browser detection versus feature detection

I have been reading about feature detection (using Google/Wikipedia/Docs) but don’t quite get a grip of it. Some questions pop up

  1. Why is Feature Detection needed. Can’t we just detect the browser and write code for it?
  2. Different ways to do feature detection. Best of them all?
  3. Can you give me a practical real world example where Feature Detection works. How do we handle old browsers and how to replicate the same feature in them>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:36:47+00:00Added an answer on June 13, 2026 at 11:36 pm

    Why is Feature Detection needed. Can’t we just detect the browser and write code for it?

    No, very quickly your list of what each browser does gets out of date, and it will by its very nature be incomplete. (Does the blackberry browser from three years ago support placeholder text in inputs? I have no idea, nor do I need to care.) For example, it used to be that IE didn’t have addEventListener. Now it does. If you start detecting all the way down to the browser version level, then what do you do when new versions come out? It’s a maintenance nightmare.

    Different ways to do feature detection. Best of them all?

    There is no single feature detection, it depends on the feature. You can find a great list of feature detections on this page. There are also libraries like Modernizr that will do the feature-detection for you.

    Can you give me a practical real world example where Feature Detection works. How do we handle old browsers and how to replicate the same feature in them>

    Sure. I gave you two above, let’s dig into them a bit (in reverse order).

    addEventListener: This is a common thing to see in code that doesn’t use a library like jQuery, YUI, and the like:

    if (elm.addEventListener) {
        // Standard
        elm.addEventListener("click", myClickHandler, false);
    }
    else if (elm.attachEvent) {
        // IE fallback
        elm.attachEvent("onclick", myClickHandler);
    }
    

    The great thing about the code above is that when IE9 came out and had addEventListener (in standards mode), code just worked. No need to update a database to say “IE9 has it now.”

    Or there’s placeholder text in input fields, e.g.:

    <input type="text" name="firstName" placeholder="First name">
    

    When browsers don’t support the placeholder text, they don’t have the placeholder property on elements; when they do, they do. So this feature-detects whether the browser supports placeholders:

    if ('placeholder' in document.createElement('input')) {
        // Supports the placeholders
    }
    else {
        // Doesn't, need to do something
    }
    

    If it doesn’t, you might hook up code to do it yourself. I do that in my place5 plug-in, which is a polyfill for this functionality.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Open child browser window from child window I have a list of
Possible Duplicate: Change the URL in the browser without loading the new page using
Possible Duplicate: How to disable browser or element scrollbar, but allow scrolling with wheel
Possible Duplicate: How to disable minimize, maximize button in the browser? I am using
Possible Duplicate: Javascript: Setting window.location.href versus window.location When I tested these code in browser
Possible Duplicate: Browser detection in javascript? I was wondering how can I detect IE
Possible Duplicate: Browser-independent way to detect when image has been loaded How can i
Possible Duplicate: How to prevent duplicate posts via a browser refresh? I have a
Possible Duplicate: Javascript To Get An Alert When Closing The Browser Window I have
Possible Duplicate: Disable browser's back button I have a log in page <div style=border:1px

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.