473,385 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.appVersion.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 2306
pe**********@gmail.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.appVersion.indexOf("Mac")!==-1) ? true : false;
What does the navigator.appVersion 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.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 30 '06 #2

Randy Webb wrote:
pe**********@gmail.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
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...
20
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...
3
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 =...
3
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...
79
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...
7
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"...
1
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? ...
15
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...
10
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.