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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:52:31+00:00 2026-05-29T22:52:31+00:00

This code snippet used to work. I think a recent update of Google Chrome

  • 0

This code snippet used to work. I think a recent update of Google Chrome broke it. Does anyone else see this?

function DenyIfTablet() {
    try {
        document.createEvent("TouchEvent");
        alert("Silverlight not supported on touch-screen devices.");
        window.location = document.referrer;
    }
    catch(exception){ 
        //OK to continue.
    }
}

Under IE9 an exception is thrown and the alert/redirect does not occur.

Under Chrome 17.0.963.43 an exception is not thrown and I am redirected away, even though I am not using a touch screen device.

Am I doing something improper here, or did the rug just get pulled out beneath me in a Chrome update?

  • 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-29T22:52:33+00:00Added an answer on May 29, 2026 at 10:52 pm

    Yes, there was some change in Chrome 17 and 18 that made that test not work, but it works again in 19. However, that test probably isn’t robust enough in the face of the many different ways browsers choose to express their support for touch.

    The modernizr guys did a bunch of research on this, with the results over many hundreds of versions of browsers, mobile and desktop, here:

    http://modernizr.github.com/Modernizr/touch.html

    My understanding is that for better or worse (mostly worse), there isn’t a silver bullet for detecting support (or even an agreed upon standard way of doing so someday).

    The primary way modernizr detects support is

    ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch
    

    but then they proceed to inject an element with a ‘touch-enabled’ media query and test if it has an effect to be extra sure (it’s a little hard to follow, but check out the source).

    So, I would at least consider switching to testing for ontouchstart (which looks closest to right in that browserscope list), but, if you really want to get it right, I would just use modernizr.

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

Sidebar

Related Questions

This code actually used to work until now. I have no idea what is
This code snippet is from C# in Depth static bool AreReferencesEqual<T>(T first, T second)
Take this code snippet for example: window.location.href = 'mysite.htm#images'; Already being on the site
VS 2008 I have this code snippet I found on a VB website. But
I have this code snippet: <div id=div1> </div> <div id=div2> <h3>This is the content</h3>
A friend gave me this code snippet in Clojure (defn sum [coll acc] (if
I am using this code snippet to add KeyDown event handler to any element
I have this code snippet inside a function that checks if an object exists
I saw this code snippet during our lab and it actually compiles in MSVC2008
For example result of this code snippet depends on which machine: the compiler machine

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.