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

  • Home
  • SEARCH
  • 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 8311423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:48:42+00:00 2026-06-08T19:48:42+00:00

So I’m trying to move a close button to the left side when the

  • 0

So I’m trying to move a “close” button to the left side when the user is on Mac and the right side when the user is on PC. Now I’m doing it by examining the user agent, but it can be too easily spoofed for reliable OS detection. Is there a surefire way to detect whether the OS on which the browser is running is Mac OS X or Windows? If not, what’s better than user agent sniffing?

  • 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-06-08T19:48:43+00:00Added an answer on June 8, 2026 at 7:48 pm

    The window.navigator.platform property is not spoofed when the userAgent string is changed.
    I tested on my Mac if I change the userAgent to iPhone or Chrome Windows, navigator.platform remains MacIntel.

    navigator.platform is not spoofed when the userAgent string is changed

    The property is also read-only

    navigator.platform is read-only


    I could came up with the following table

    Mac Computers

    Mac68K Macintosh 68K system.
    MacPPC Macintosh PowerPC system.
    MacIntel Macintosh Intel system.
    MacIntel Apple Silicon (ARM)

    iOS Devices

    iPhone iPhone.
    iPod iPod Touch.
    iPad iPad.


    Modern macs returns navigator.platform == "MacIntel" but to give some "future proof" don’t use exact matching, hopefully they will change to something like MacARM or MacQuantum in future.

    var isMac = navigator.platform.toUpperCase().indexOf('MAC')>=0;
    

    To include iOS that also use the "left side"

    var isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
    var isIOS = /(iPhone|iPod|iPad)/i.test(navigator.platform);
    
    var is_OSX = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
    var is_iOS = /(iPhone|iPod|iPad)/i.test(navigator.platform);
    
    var is_Mac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
    var is_iPhone = navigator.platform == "iPhone";
    var is_iPod = navigator.platform == "iPod";
    var is_iPad = navigator.platform == "iPad";
    
    /* Output */
    var out = document.getElementById('out');
    if (!is_OSX) out.innerHTML += "This NOT a Mac or an iOS Device!";
    if (is_Mac) out.innerHTML += "This is a Mac Computer!\n";
    if (is_iOS) out.innerHTML += "You're using an iOS Device!\n";
    if (is_iPhone) out.innerHTML += "This is an iPhone!";
    if (is_iPod) out.innerHTML += "This is an iPod Touch!";
    if (is_iPad) out.innerHTML += "This is an iPad!";
    out.innerHTML += "\nPlatform: " + navigator.platform;
    <pre id="out"></pre>

    Since most O.S. use the close button on the right, you can just move the close button to the left when the user is on a MacLike O.S., otherwise isn’t a problem if you put it on the most common side, the right.

    setTimeout(test, 1000); //delay for demonstration
    
    function test() {
    
      var mac = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
    
      if (mac) {
        document.getElementById('close').classList.add("left");
      }
    }
    #window {
      position: absolute;
      margin: 1em;
      width: 300px;
      padding: 10px;
      border: 1px solid gray;
      background-color: #DDD;
      text-align: center;
      box-shadow: 0px 1px 3px #000;
    }
    #close {
      position: absolute;
      top: 0px;
      right: 0px;
      width: 22px;
      height: 22px;
      margin: -12px;
      box-shadow: 0px 1px 3px #000;
      background-color: #000;
      border: 2px solid #FFF;
      border-radius: 22px;
      color: #FFF;
      text-align: center;
      font: 14px"Comic Sans MS", Monaco;
    }
    #close.left{
      left: 0px;
    }
    <div id="window">
      <div id="close">x</div>
      <p>Hello!</p>
      <p>If the "close button" change to the left side</p>
      <p>you're on a Mac like system!</p>
    </div>

    http://www.nczonline.net/blog/2007/12/17/don-t-forget-navigator-platform/

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

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I need to clean up various Word 'smart' characters in user input, including but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into

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.