www.webdeveloper.com
Results 1 to 5 of 5

Thread: cgi, perl, php browser detection

  1. #1
    Join Date
    Dec 2002
    Location
    hawaii
    Posts
    13

    Question cgi, perl, php browser detection

    Ok before you say go to the javascript section wait...
    I am wondering if there is a way to detect the browser type and version so as to redirect certain browser/version combos to a diferent area/html page. As was pointed out to me in the javascript section, if they have js turned off the js detection will not work, my boss gets angry letters saying our site is 'broken' etc ad nauseum.

    So can it work? I really suck at perl took me 3-1/2 hrs just to stop the formail script from sending every 0.00 in my reservation form to the mail and html responses.

    Blah blah blah, I digress....so can it?...any takers???
    If it makes a dif' I have a good relationship with my ISP

    Aloha Chris

  2. #2
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    You can get browser and os type and version through the HTTP_USER_AGENT environment variable. It could appear as the following

    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)


    You can use the HTTP::Headers::UserAgent module to parse this information.

    But this still will not tell you whether the user has JavaScript enabled or not. What you could do is have your index page the non-js version with an embed script to redirect to the js version. If they have js enabled then they'll be redirected to the js page, otherwise they remain on the non-js page.
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  3. #3
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    If you are using Perl then you might find it easier to use the user_agent() function/method of the ubiquitous CGI.pm module (http://theoryx5.uwinnipeg.ca/CPAN/da...MENT_VARIABLES).

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    And furthermore,
    Using JavaScript to redirect away from the JavaScript free version doesn't work if somebody links to the JavaScript dependent page. Your client will still get those nasty comments. The solution is to use JavaScript in such a way that your page still 'fails safe'. Back up all of your client side form validation server side. Use <a href="http://www.w3.org" onclick="window.open(this.href)">W3C</a> to open a pop up window. Use server side includes. There's always a way, you just have to be clever about it.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  5. #5
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    If you are using Perl then you might find it easier to use the user_agent() function/method of the ubiquitous CGI.pm module

    This is actually a rather useless area of CGI.pm. Loading a module and calling a method seems rather silly when the same value is already easily accesible through a preloaded variable.

    $ENV{HTTP_USER_AGENT}

    Likewise [quoteIf you give this method a single argument, it will attempt to pattern match on it, allowing you to do something like $query->user_agent(netscape);[/quote] is also pointless as it replaces only a single statement that must again be loaded and executed from a module.

    /netscape/i;
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles