Restricting to desktop

PennController for IBEX Forums Support Restricting to desktop

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #5767


    I’ve searched through the forum here and don’t *think* I’ve seen this issue exactly addressed, but forgive me if it is. We want to ensure that only desktop users (or at least not phones) can do our SPR study – or at least to have a way of tracking this. I’ve seen other experiments that have browser/OS checks and so on, but I do not know how that is done and if it would help. Any thoughts/tips?




    There’s no bulletproof method to ensure that someone is using a desktop rather than a phone or a tablet, but there are good approximation methods.

    One option is to check the width of the screen:

        newFunction( ()=>window.matchMedia("only screen and (max-width: 760px)").matches )
                newText("<p>We're sorry but this experiment requires a wider resolution.</p>"+
                        "<p>Please do not use a modile device to take this experiment.</p>"+
                        "<p>If you are using a desktop browser, make sure to maximize this window.</p>")

    Another solution is to use user agent sniffing:

    newFunction( ()=>navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) )



    Another simple feature that makes it at least very hard (possibly impossible, not sure) to proceed in an experiment with a device without a physical keyboard is to just include a ‘press space to continue’ step, using newKey(). Without a text input field, there generally is no straightforward way (if any, haven’t found one) to bring up the virtual keyboard on a phone or iPad, which means you cannot continue. (I learned this by accident in a recent study where I was leaving tablet use as an option on Prolific, and had lots of people falter precisely for this reason.) Thinking on it, I wonder whether self-paced reading would work on devices without a keyboard to begin with – is there any way to proceed within a sentence without pressing a keyboard key?


    As for spr even being possible on a phone: i found that iphones (n=2 types) would display a “Next” button to progress through the regions (but yes – as you say – I get stalled at a “press any key to continue” screen). I was just surprise that this Next button appears on the phone when on a desktop one just presses the spacebar to proceed. This is native Ibex.


    Alex Drummond wrote this in utils.js: var isIPhone = navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i);

    And the code of DashedSentence contains a conditional on isIPhone to print the “Next” button. I guess the longer term idea was to expand the check to any mobile browser (remember that Alex started writing ibex in the early 2010s)



    User Agent detection is not a recommended technique for modern web apps. You can use JavaScript window.matchMedia() method to detect a mobile device based on the CSS media query.

    if (window.matchMedia("(max-width: 767px)").matches)
    // The viewport is less than 768 pixels wide
    document.write("This is a mobile device.");

    Another approach would be a responsive media query. You could presume that a mobile phone has a screen size greater than x and less than y.

    For example:

    @media only screen and (min-width: 320px) and (max-width: 600px) {}

    You may also use .

    const isMobile =;


    Thank you for the detailed updates

    Unfortunately is not currently supported by Firefox and Safari according to MDN Web Docs

    Checking the min/max width of the page is indeed a minimally intrusive proxy, although it doesn’t really check whether the participant is using a mobile device—admittedly, user agent sniffing also has its limits, as it can be tweaked by the client


Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.