Detect and Change User Agent Via Javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rainmanjam

    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?
  • RobG

    #2
    Re: Detect and Change User Agent Via Javascript

    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

    Comment

    • Rainmanjam

      #3
      Re: Detect and Change User Agent Via Javascript

      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

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Detect and Change User Agent Via Javascript

        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

        Comment

        • David Mark

          #5
          Re: Detect and Change User Agent Via Javascript

          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.

          Comment

          • Rainmanjam

            #6
            Re: Detect and Change User Agent Via Javascript

            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.

            Comment

            Working...