Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
Simplify my event listening device and orientation detection code

First im more of a designer than developper. I have a code to detect if my browser is in mobile and portrait to change some class. I'm pretty sure this can be simplify

Tanks

window.addEventListener("load", function(){
        if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) &&  window.matchMedia("(orientation: portrait)").matches) {
                console.log("this is mobile and portrait");
        }else{
            console.log("this is not mobile");
        }
    });

    window.addEventListener("resize", function(){
        if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) &&  window.matchMedia("(orientation: portrait)").matches) {
                console.log("this is mobile and portrait");
        }else{
            console.log("this is not mobile");
        }
    });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!