473,407 Members | 2,598 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,407 software developers and data experts.

Detect and Change User Agent Via Javascript

I have a web site that uses MSN Live Maps. It works in Opera if I
change the User Agent to IE. Is there a way to change the User Agent
via Javascript for one page?
Dec 27 '07 #1
5 11662
On Dec 27, 8:34*pm, Rainmanjam <nject...@gmail.comwrote:
I have a web site that uses MSN Live Maps. It works in Opera if I
change the User Agent to IE. Is there a way to change the User Agent
via Javascript for one page?
Find whatever variable is used to store the user agent (usually
something like var IE = true/false) and just set it to true. But I
expect that will break much more than it fixes.

From the little I have seen of MS Live Maps, I wouldn't use it for a
web site. It uses extensive browser sniffing and requires the
download of a 750kB script file. In another thread, I did a search
for the string "attachEvent" and got 234 hits whereas addEventListener
only rated 11 - seems to me it is deliberately designed to provide
more features for IE than any other browser.

Now that is fine, MS are quite at liberty to create IE-specific web
libraries, but if you want a site that works well in other browsers,
don't use it.
--
Rob
Dec 27 '07 #2
On Dec 27, 3:19 am, RobG <rg...@iinet.net.auwrote:
On Dec 27, 8:34 pm, Rainmanjam <nject...@gmail.comwrote:
I have a web site that uses MSN Live Maps. It works in Opera if I
change the User Agent to IE. Is there a way to change the User Agent
via Javascript for one page?

Find whatever variable is used to store the user agent (usually
something like var IE = true/false) and just set it to true. But I
expect that will break much more than it fixes.

From the little I have seen of MS Live Maps, I wouldn't use it for a
web site. It uses extensive browser sniffing and requires the
download of a 750kB script file. In another thread, I did a search
for the string "attachEvent" and got 234 hits whereas addEventListener
only rated 11 - seems to me it is deliberately designed to provide
more features for IE than any other browser.

Now that is fine, MS are quite at liberty to create IE-specific web
libraries, but if you want a site that works well in other browsers,
don't use it.

--
Rob
I understand what you are saying but MS live maps is a requirement of
a project I am doing. I figured it out and posting results:
if (browser.indexOf("Opera") >= 0 )

{

navigator.userAgent="Mozilla/5.0 (compatible; MSIE 7.0; Windows NT
5.2)";

}

Easy Peazy
Dec 27 '07 #3
Rainmanjam wrote:
On Dec 27, 3:19 am, RobG <rg...@iinet.net.auwrote:
>[MS Live Maps is not suitable for the Web]

I understand what you are saying but MS live maps is a requirement of
a project I am doing. I figured it out and posting results:
if (browser.indexOf("Opera") >= 0 )

{

navigator.userAgent="Mozilla/5.0 (compatible; MSIE 7.0; Windows NT
5.2)";

}

Easy Peazy
Hardly. Assignment to navigator.userAgent might not even be possible,
throwing an exception.

Please trim your quotes.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Dec 27 '07 #4
On Dec 27, 6:07*pm, Rainmanjam <nject...@gmail.comwrote:

[snip]
>
Interesting. I plugged the above javascript on my sitehttp://njection.com/speedtrap
Not really.
and it works just fine. Tried it on several versions of Opera.
Oddly enough, that browser wasn't among the test cases.

So it works on Opera and virtually nothing else (and may throw an
exception in some agents.) Regardless, it's a completely ridiculous
thing to do.

BTW, some versions of Opera allow the user to change the userAgent
string to eliminate the "Opera" portion. This is one of many reasons
that browser sniffing cannot be relied upon.
Dec 27 '07 #5
On Dec 27, 3:13 pm, David Mark <dmark.cins...@gmail.comwrote:
On Dec 27, 6:07 pm, Rainmanjam <nject...@gmail.comwrote:

[snip]
Interesting. I plugged the above javascript on my sitehttp://njection.com/speedtrap

Not really.
and it works just fine. Tried it on several versions of Opera.

Oddly enough, that browser wasn't among the test cases.

So it works on Opera and virtually nothing else (and may throw an
exception in some agents.) Regardless, it's a completely ridiculous
thing to do.

BTW, some versions of Opera allow the user to change the userAgent
string to eliminate the "Opera" portion. This is one of many reasons
that browser sniffing cannot be relied upon.
I totally understand. This case was just with Opera and getting it
working with MS Live Maps. Thank you for your feedback.
Dec 27 '07 #6

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

Similar topics

60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
1
by: Barry Svee | last post by:
I'm struggling with the JavaScript blur event. I have an activex control that I need to interact with when a window loses focus, namely to instruct it to give up control of a barcode scanner so...
3
by: Raj | last post by:
Hi All, Is it possible to detect if a client software is installed on a machine using browser javascript. we are building a web/windows software and when the user logs into the web application,...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
7
by: Keith Smith | last post by:
How can I change the background IMAGE (not just color) of a CELL in a table? I know that I can do this using CSS, but I really need to be able to do it using JavaScript. Anyone know how? Must...
5
by: Andy | last post by:
Hi, I'm trying to use javascript to detect the version of internet explorer before running an active x control. I'm after the full version number (eg not just IE6 but 6.0.2800.1106). Is there...
9
by: Rich | last post by:
Please help. Looking for a script to detect and display what version of Windows a user is running. Thanks in advance. Rich
7
by: Baron Samedi | last post by:
I coded up a hit counter, then extended it to see who was reading my blog, by matching IP. The problem is that I am swamped by crawlers. How can I detect a human, or a crawler? If I can handle...
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: 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
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?
0
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,...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.