Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    houston, tx
    Posts
    21
    Rep Power
    0
    Just kind of curious if ther is a way that you can detect the type and version of a browser which goes to your page.

    If so, mind posting some code on it, please?

    Thanks,
    diversereality
  2. #2
  3. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by diversereality:
    Just kind of curious if ther is a way that you can detect the type and version of a browser which goes to your page.

    If so, mind posting some code on it, please?

    Thanks,
    diversereality
    [/quote]

    I'd say the simplest answer would be to make
    use of the getenv() function.

    getenv(http_user_agent);



    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    houston, tx
    Posts
    21
    Rep Power
    0
    Well, I played with getenv(), and it doesn't appear to be all that universal. What I am attempting to do is make some form of script, either in javascript or php, that detects the browser and then makes a CSS link based on the browser.

    I have been playing with both php and javascript on this, but havn't gotten anything to work, yet.

    Any help/code is appreciated

    Thanks
    diversereality
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    114
    Rep Power
    14
    If you're using PHP4, just say
    echo $HTTP_USER_AGENT;
    and you should see something similar to, javascript's
    document.write(navigator.appVersion);
    A quick and dirty way to find out if the page is going to a Netscape or IE browser is to say:

    ereg("MSIE",$HTTP_USER_AGENT) ? $browser="IE" : $browser="NN";

    If you're worried about platforms, screen widths, or color depth, I'd say make your pages more simple, or use JavaScript.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    houston, tx
    Posts
    21
    Rep Power
    0
    ereg("MSIE",$HTTP_USER_AGENT) ? $browser="IE" : $browser="NN";

    Ok, just a few questions. What does ereg() do/mean?

    And isn't * ? * : * ; stand for something along the lines of If * then * else *?

    Oh, and one last thing. Everytime I get on my site under Netscape, it crashes Netscape. IE works fine, though.

    Thanks,
    diversereality
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    114
    Rep Power
    14
    ereg(pattern, string, [array_of_matches])

    if the pattern is found in the string, ereg returns true, else it returns false. Optionally, you can put in an array in for the third argument and it will hold the matches. The ternary operator ? just says "is this true?" So
    1==1 ? $answer="true" : $answer="false";
    echo $answer; // should show "true";


    If you look at the string returned by $HTTP_USER_AGENT, you'll find that "MSIE" is in it for Microsoft Internet Explorer, and not netscape. So

    is it microsoft ? yes, browser is IE : no, browser is netscape;

    Quick and dirty because there are a host of other browsers that are not IE and not NN. PHP runs on the server side so it usually not to blame for browsers crashing, however maybe if you're trying to set a cookie it might make it crash? More likely it's just some bad HTML or JavaScript.
  12. #7
  13. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    I would suggest you to do this in javascript...since the issue is with client side just sort it out thier itself..

    you can find out some free browser validation script from the net..

    See an example :

    <SCRIPT LANGUAGE="JAVASCRIPT">

    // -----------------------------------------------------------------
    // Function : FullBrowserDetection
    // Description : Detect browser name and version
    //Generated by : HTMLGATE2000
    // -----------------------------------------------------------------

    if (Browser.netscape)
    {
    if (Browser.version<3)
    {
    // Netscape1.x or Netscape2.x

    }
    else
    {
    if (Browser.version<4)
    {
    // Netscape3.x

    }
    else
    {
    if (Browser.version<5)
    {
    // Netscape4.x

    }
    }
    }
    }
    if (Browser.ie)
    {
    if (Browser.version<3)
    {
    // IE1.x or IE2.x

    }
    else
    {
    if (Browser.version<4)
    {
    // IE3.x

    }
    else
    {
    if (Browser.version<5)
    {
    // IE4.x

    }
    }
    }
    }
    if (Browser.other)
    {
    }

    </SCRIPT>

    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    houston, tx
    Posts
    21
    Rep Power
    0
    Well, I have code for javascript, and such, but don't know how to make it print out the <link blah blah> part without generating an error.

    The php version works like a charm, cept that my coding crashes netscape, now.

    Regards,
    diversereality
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    114
    Rep Power
    14
    Could you post a link to your page? I seriously doubt that PHP has anything to do with netscape crashing.
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    houston, tx
    Posts
    21
    Rep Power
    0
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    houston, tx
    Posts
    21
    Rep Power
    0
    Oh, forgot to put text with the link. For the past day, or two, now, I have been going over the coding for my site, but guess I don't know Netscape that well...

    If anyone could help, I would really appreciate it.

    Thanks,
    diversereality
  22. #12
  23. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    please go to the following page:
    http://www.phpbuilder.com/columns/ti...21.php3?page=2

    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    114
    Rep Power
    14
    I tried loading just the HTML of your page into netscape, and it crashed. So it definitely not the PHP.
  26. #14
  27. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    houston, tx
    Posts
    21
    Rep Power
    0
    That was a nice site(php builder). Thanks for posting it.

    Oh, and if anyone realizes what is crashing Netsacpe regading my site, please let me know.

    Thanks,
    diversereality
  28. #15
  29. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    <p class="Frame">

    could be a CSS thing but more likely that NS does not like you using 'frame' as a class - its almost certainly a reserved word - rename it and see what happens - if you drop the class altogether it works in 4.7 but obviously without the frame around the text - I did not look at the css.

    Simon Wheeler
    FirePages -DHTML/PHP/MySQL

    [This message has been edited by firepages (edited September 28, 2000).]
Page 1 of 2 12 Last
  • Jump to page:

Similar Threads

  1. kids browser creation...
    By itd_network in forum Hire A Programmer
    Replies: 0
    Last Post: February 15th, 2004, 11:23 AM
  2. PHP with UnixODBC
    By coder4hire in forum PHP Development
    Replies: 2
    Last Post: January 20th, 2004, 01:14 PM
  3. Pass Perl variable through PHP to browser?
    By dvd in forum Perl Programming
    Replies: 6
    Last Post: January 18th, 2004, 01:37 PM
  4. Format RSS in a web browser using PHP
    By jabba_29 in forum PHP Development
    Replies: 3
    Last Post: January 16th, 2004, 07:20 AM
  5. UnixODBC + PHP + Apache + Empress
    By coder4hire in forum Database Management
    Replies: 0
    Last Post: January 15th, 2004, 01:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo