Restricting to desktop

PennController for IBEX Forums Support Restricting to desktop

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

    Hi,

    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?

    Thanks

    #5770
    Jeremy
    Keymaster

    Hi,

    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:

    newTrial(
        newFunction( ()=>window.matchMedia("only screen and (max-width: 760px)").matches )
            .test.is(true)
            .success( 
                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>")
                    .print()
                ,
                newButton().wait() 
            )
    )

    Another solution is to use user agent sniffing:

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

    Jeremy

    #5774
    florians
    Moderator

    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?

    #5792
    kmoulton
    Participant

    thanks!!
    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.

    #5793
    Jeremy
    Keymaster

    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)

    Jeremy

    #7673
    murphybeck
    Participant

    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 navigator.userAgentData.mobile .

    const isMobile = navigator.userAgentData.mobile;

    #7679
    Jeremy
    Keymaster

    Thank you for the detailed updates

    Unfortunately navigator.userAgentData.mobile 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

    Jeremy

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