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 6671221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:21:44+00:00 2026-05-26T03:21:44+00:00

Reading this article I’ve found a following piece of code: if (‘v’==’\v’) { //

  • 0

Reading this article I’ve found a following piece of code:

if ('v'=='\v') { // Note: IE listens on document
    document.attachEvent('onstorage', onStorage, false);
}

Is this method 'v'=='\v' a great idea? Is this the shortest way to detect IE ever?

  • 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-05-26T03:21:45+00:00Added an answer on May 26, 2026 at 3:21 am

    If you can avoid it, don’t test for browsers. Do feature detection. This will mean that your code is (more likely to be) future-proof. In this case, for instance, if you discovered that the browser was IE and decided to use attachEvent because of it, you would miss out on the fact that addEventListener (superior) is available in IE9.

    In this case, test to see if document.addEventListener exists. If it does, you have the answer.

    if (document.addEventListener) {
        document.addEventListener(...);
    } else {
        document.attachEvent(...);
    }
    

    Edit: duri’s comment above shows that this test fails in IE9 (as per standards), which actually means it is a perfect test for addEventListener, since that is available from IE9. However it is still far, far better to program for specific functionality, rather than specific browsers.

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

Sidebar

Related Questions

Reading this article I found several ways to call a method. Method to call:
I was just reading this article :- http://css-tricks.com/perfect-full-page-background-image/ Please note this css :- #bg
I am following the spring MVC tutorial and also reading this article on mvc
I was reading this article and I came across the following definition (in qglobal.h
After reading this article http://camendesign.com/code/developpeurs_sans_frontieres I have decided to follow what it says and
I came across this code showing format string exploitation while reading this article. #include
I was reading this article about ADO.NET Entity Framework and found it to be
I was reading this article : Frame Buster Buster ... buster code needed I
After reading this article on thedailywtf.com, I'm not sure that I really got the
After reading this article http://lukast.mediablog.sk/log/?p=155 I decided to use mingw on linux to compile

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.