473,699 Members | 2,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detecting Mac OS X (When feature detection doesn't work?)

Hi,

I don't know if there is a way to feature detect for this or not. I
have a list and the user can click on items to select. I would like
that they can command-click on Mac or control-click on other OS to
multiple select. This matches normal file system behavior.

I found this example which doesn't seem to work in Opera on Mac: the
mac variable will be false.

var mac = (navigator.appV ersion.indexOf( "Mac")!==-1) ? true : false;

if (mac && e.metaKey) || (!mac && e.ctrlKey) {
// do multiple selection
}

So is there a way to feature detect for what I'm doing?

Is there a reliable way to know if the OS is Mac or not?

Thanks,
Peter

Jul 30 '06 #1
2 2323
pe**********@gm ail.com said the following on 7/30/2006 1:24 PM:
Hi,

I don't know if there is a way to feature detect for this or not. I
have a list and the user can click on items to select. I would like
that they can command-click on Mac or control-click on other OS to
multiple select. This matches normal file system behavior.

I found this example which doesn't seem to work in Opera on Mac: the
mac variable will be false.

var mac = (navigator.appV ersion.indexOf( "Mac")!==-1) ? true : false;
What does the navigator.appVe rsion give for Opera on the Mac? It could
be nothing more than a lowercase m versus uppercase M.
if (mac && e.metaKey) || (!mac && e.ctrlKey) {
// do multiple selection
}

So is there a way to feature detect for what I'm doing?
What you are doing above is not "feature detecting" though, it is OS
detection based on your "mac" variable. What happens if you drop the OS
code all together?

if (e.metaKey || e.ctrlKey){

}
Is there a reliable way to know if the OS is Mac or not?
Not if your method is based on the navigator object and it's spoof-able
properties.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 30 '06 #2

Randy Webb wrote:
pe**********@gm ail.com said the following on 7/30/2006 1:24 PM:
Hi,

I don't know if there is a way to feature detect for this or not. I
have a list and the user can click on items to select. I would like
that they can command-click on Mac or control-click on other OS to
multiple select. This matches normal file system behavior.

I found this example which doesn't seem to work in Opera on Mac: the
mac variable will be false.
Randy,

Thanks for the ideas. I tried your ideas but it turns out that maybe
Opera just doesn't support e.metaKey eventhough their site says it
does.

This is old but says opera will always return false

http://www.quirksmode.org/dom/w3c_events.html

My tests show the same.

Peter

Jul 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5175
by: Holden Caulfield | last post by:
Does anyone know how to detect if a user has pasted code using the right mouse button into a textarea? I have fields in a form that autoupdate when text is changed in a textarea, but if it is pasted using the mouse (not CTRL-V) the trigger doesn't happen. I tried onChange first, no luck. Detecting keystrokes and LEFT mouseclicks was easy enough, and it works for those. But SOME users paste stuff in without ever typing or...
20
7919
by: Mandy Memphis | last post by:
If I perform a mousedown within a document, move the mouse outside the browser window, and then release the mouse button, the document.onmouseup event does not fire. Is there any way to detect a mouseup event outside the document? Also, how can I get the relative coordinates of the cursor while it is outside the browser? Thank you.
3
1730
by: Ricardo Garcia | last post by:
hi, i was just wondering about javascript version i used to do it putting in the <head>: <script type="text/javascript"> jsver = "1.0"; </script> <script language="JavaScript1.1"> jsver = "1.1"; </script> <script language="JavaScript1.2">
3
3609
by: regtrashcan | last post by:
I have a webpage that detects whether Shockwave Player is installed and the version number. The javascript/vbscript that I use has worked fine until the latest release of the Shockwave Player. I am still able to detect the Shockwave Player and the version number when using Firefox/Netscape, but not with IE. I have my own detection script that I use, but I've also used the detection scripts supplied from Macromedia, but it still won't...
79
3765
by: VK | last post by:
I wandering about the common proctice of some UA's producers to spoof the UA string to pretend to be another browser (most often IE). Shouldn't it be considered as a trademark violation of the relevant name owner? If I make a whisky and call it "Jack Daniels", I most probably will have some serious legal problems. "Mozilla" partially appeared because NCSA stopped them from using "Mosaic" in the UA string. Is it some different...
7
2998
by: Nathan Sokalski | last post by:
I want to make sure I am doing a browser detection that will work once IE7 is released. My current detection statement (written using VB.NET) is: If Me.Request.Browser.Browser.ToUpper() = "IE" Then 'Code to use for Internet Explorer browsers Else 'Code to use for browsers other than Internet Explorer End If
1
2016
by: olaolu143 | last post by:
Hello! I am doing my BSc Hons final year project in the above topic (Detecting Masquerading using Intrusion Detection System). Can you please give me any suggestions or materials to help me? I will like to make the system Host based to start with, this is because I have only 3 months to complete the project. Can you please advice me on which technique to use for anomaly detection?
15
4224
by: RobG | last post by:
When using createEvent, an eventType parameter must be provided as an argument. This can be one of those specified in DOM 2 or 3 Events, or it might be a proprietary eventType. My problem is testing for support of particular eventTypes - the DOM 2 Events Interface DocumentEvent says that if the eventType is not supported, it throws a DOM exception. This makes testing rather tough - if you try something like: if (document &&...
10
3254
by: Conrad Lender | last post by:
In a recent thread in this group, I said that in some cases object detection and feature tests weren't sufficient in the development of cross-browser applications, and that there were situations where you could improve the application by detecting the browser vendor/version. Some of the posters here disagreed. Since then, I've had to deal with a few of these cases; some of them could be rewritten to use object detection, and some couldn't....
0
8704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8623
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9187
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9054
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8936
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7777
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3071
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.