Rainmanjam said:
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 )
Are you testing to make sure "Opera" is in the string here? Yes. But
you're not testing for the false value String.indexOf will give you back
reliably, which is -1. That line should really be:
if (browser.indexOf("Opera") != -1 )
In this case it doesn't hurt you, but it's a good practice, and will
make your code more readable, IMHO.
As var as the code itself:
<script type="text/javascript">
var browser = navigator.userAgent;
if (browser.indexOf("Opera") >= 0 )
{
navigator.userAgent="Mozilla/5.0 (compatible; MSIE 7.0; Windows NT5.2)";
}
document.write (navigator.userAgent);
// Firefox writes:
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.11)
Gecko/20071127 Firefox/2.0.0.11
// IE7 writes:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Comcast Install 1.0;
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET
CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)
// Safari on Win writes:
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/523.13
(KHTML, like Gecko) Version/3.0 Safari/523.13
</script>
So it appears to me from the actual tests that you can't modify it. This
works for you? I would be careful with the assumption that it will
continue to do so. IMHO, of course.
~A!