473,804 Members | 3,094 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11687
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 "attachEven t" and got 234 hits whereas addEventListene r
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.ne t.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 "attachEven t" and got 234 hits whereas addEventListene r
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.indexO f("Opera") >= 0 )

{

navigator.userA gent="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.ne t.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.indexO f("Opera") >= 0 )

{

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

}

Easy Peazy
Hardly. Assignment to navigator.userA gent 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
7314
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 The detector requires javascript 1.0 to work. This translates to netscape 2.0 and IE 3.0 (although maybe IE 2.0 also works with it)
1
16606
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 that the application being brought foreward can take control. It has been my observation that when I set the window.onblur function, the window will gain focus and then immediately lose focus (blur) to the first field, button, or whatever that is...
3
9343
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, we want to detect if our software is installed on the client machine and if so we want to provide more access, or else we want to give the user a limited access to the web site Thanks in Advance
4
2636
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 QA tested for a new year release. I don't think that going to prove practical, but there is no harm in trying :) and some serious family commitments. But it has to be done soon so this is stage one. Mike Winter provided an extensive list of...
7
4852
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 be able to change the image for each cell - not the whole table. Please help.
5
3460
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 any way of getting this using javascript? If not, can anybody suggest how i could go about getting it? many thanks in advance,
9
11599
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
9158
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 one, I can negate it for the other. Should I somehow user $_SERVER ? or something else? Thanks in advance.
0
10558
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
10318
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
10302
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
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
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
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2975
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.