Thread: [PHP-ASP] Retrieving client (windows)OS language

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    69

    [PHP-ASP] Retrieving client (windows)OS language

    I have to write a web page that determines the client OS language and then redirects the browser to the appropriate page (possibly in the same language).

    Suppose the client browsers run on Windows NT/XP/2000/2003
    Using client-side scripting, i can do it in this way:

    Code:
    <html>
    <body>
    
    <script language="vbscript">
    
    For Each objOperatingSystem in GetObject( "winmgmts:").InstancesOf ("Win32_OperatingSystem") 
    
               ' this cycle should be executed only once
    
          if objOperatingSystem.OSLanguage = 9 then       
            'go to English page
           location.href = "http://mypage.com/english.html"
          elseif objOperatingSystem.OSLanguage = 1041 then       
            'go to Japanese page
           location.href = "http://mypage.com/jap.html"
             ' etc...
          end if
    
    Next
    
    </script>
    
    </body>
    </html>
    The problem with the client-side approach is that IE will ask the user if he wants to execute the page or not, because it will detect active content within the script (the GetObject( ) call i guess).

    I just want the page be opened without asking the user.

    I think that retrieving client OS from server side will solve the problem, but is there a way to do it? using PHP, for example..

    thanks in advance

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    69

    Unhappy

    i've just read it, thank you ...
    unfortunately, it does not help.. it can retrieve some information about the browser name, version, its capabilities, and the name of the operating system, not the language

  4. #4
    Sasquatch mog's Avatar
    Join Date
    Dec 2006
    Location
    Caves of Narshe
    Posts
    16
    You can look at Accept-Language -header that most browsers send when entering a webpage.

  5. #5
    Registered User
    Join Date
    Mar 2005
    Posts
    69
    you're right thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Socket Programming Problem!!!!
    By bobthebullet990 in forum Networking/Device Communication
    Replies: 2
    Last Post: 02-21-2008, 07:36 PM
  2. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 09:09 AM
  3. WSAAsyncSelect Socket Model. She's Not Hot.
    By Tonto in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-24-2007, 08:34 AM
  4. Language of choice after C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 06-15-2004, 01:20 AM