473,379 Members | 1,185 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,379 software developers and data experts.

fooling safari with javascript

Hi,
Is it possible to fool Javascript running on a Mac Safari web
browser into believing it is a PC IE browser? We have the following JS
code that is detecting both Mac and Safari. Sadly, we do not have
control over the code.

// Global variables for platform branching
var NN, IE, MAC, browserVersion

// Flag to ensure that projectData document is loaded
var framesLoaded = false;

// Browser test
if (parseInt(navigator.appVersion) >= 4)
{
if (navigator.appName == "Netscape")
NN = true
else
IE = true
}
else
{
// browser is to old
alert("This page will not function properly in this browser because it
requires a browser version of 4.0 or above.");
}
// Version
if (IE) {
browserVersion =
navigator.appVersion.charAt(navigator.appVersion.i ndexOf("MSIE") + 5);
}
else if (NN) {
browserVersion = parseInt(navigator.appVersion);
}

// Computer test
if (navigator.appVersion.indexOf("Mac") != -1) {
MAC = true;
}

if (NN && MAC) {
alert("This activity cannot be used on a Macintosh running a Netscape
Web browser.");
back();
}

Thanks, - Dave

Oct 4 '05 #1
2 1901
la***********@zipmail.com said the following on 10/4/2005 5:00 PM:
Hi,
Is it possible to fool Javascript running on a Mac Safari web
browser into believing it is a PC IE browser? We have the following JS
code that is detecting both Mac and Safari. Sadly, we do not have
control over the code.


Then you need to fire whoever is in control of that crappy worthless code.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 4 '05 #2
la***********@zipmail.com wrote:
Hi,
Is it possible to fool Javascript running on a Mac Safari web
browser into believing it is a PC IE browser?
'JavaScript' has no concept of what a Mac running Safari is. JavaScript
and certain DOM features can be used to write a program that asks for
certain information from a browser. The browser will provide whatever
information it has been told to provide.

In the case of Safari, depending on which version, the user can elect to
have the browser masquerade as any number of browsers running on a
variety of operating systems.

Safari is certainly not alone in this respect.
We have the following JS
code that is detecting both Mac and Safari. Sadly, we do not have
control over the code.


Which I understand to mean:

"The author/vendor of this code has told us it not let anyone using
Safari running on Mac OS access the site."

So your question becomes:

"Will it work as specified?"

Without understanding why Safari users should be singled out for such
treatment, or why the programmer decided to specifically exclude certain
browsers from using the application, the answer is 'sometimes'.

The question you need to ask is:

"Why?"

Do you refuse to deal with left-handed people? Or those who refuse to
wear shoes with laces? Or those with spectacles? Excluding users based
solely on their choice of browsing platform makes about as much sense as
discriminating on any of the above factors.

The only reason to attempt browser detection and subsequently debar
certain users from site access is because of programmer incompetence.

[... rather worthless browser sniffing code removed ...]

Sorry to be harsh, but browser sniffing is bad and has been recognised
as 'worst practice' for many, many years.

Browser detection, of itself, is quite harmless. It becomes an issue
when it is used as above, that is, to prevent users accessing a site
based solely on their choice of browser. It is sure sign of lazy or
incompetent programming.

Despite the above, it still has supporters who refuse to be brought into
the 21st century. Here is a reasonably balanced article:

<URL:http://webdesign.about.com/library/weekly/aa120902a.htm>

--
Rob
Oct 4 '05 #3

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

Similar topics

4
by: Bernard | last post by:
Hi, I am suddenly getting Safari script errors with the following user agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML, like Gecko) Safari/125.8 In a...
5
by: joaopedrogoncalves | last post by:
Hi, I want to load an external javascript file, get its results and stick them inside a <div> block. I also want to do this in several places on a web page. This way the browser doesn't have...
8
by: Giuseppe Chielli | last post by:
Hi to everyone? Can someone tell me if there is a way to identify Safari...I found out that navigator.appName returns "Netscape" and I didn't found any option to change the browser's definition......
3
by: Shiva | last post by:
This is my HTML Page containing javascript --------------------------------------------------- <html> <head> <script language="JavaScript"> var isSafari = (agent.indexOf("Safari") != -1);...
13
by: Christine Forber | last post by:
How can you make a div visible and hidden in safari? document.all.style.display = "none"; Does not appear to work. Also, can anyone tell me how to turn on javascript error commenting in...
3
by: Joe Cox | last post by:
I am having a problem with style properties for dynamic images in Mac OS X Safari. By dymanic images, I mean images allocated with the javascript 'new Image()' call. With static images (created...
7
by: Tom | last post by:
I have an oo-type javascript program running perfectly on IE 6.0+, FF 1.5+, and Opera 7+ on Windows 98+, Linux (RH 9, FC 6), and Mac OS X. 4. As usual, the Safari browser is not working correctly,...
13
by: Zwerfkat | last post by:
When running the code below, all browsers are showing "Hello World" except Safari which cannot match the regular expression. See also http://www.testabc.nl/safari/test.html When I change *? into...
15
by: GinnTech | last post by:
I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the latest Safari. Here is the issue. I am attempting to call functions within a flash object. When trying to attempt to...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.