Jump to content

help with useragents and textbox's


xzmk07

Recommended Posts

Im trying to get a code working for user agents.. I want it so if the user is using Firefox, a textbox shows up with text A and if the user is using IE then a textbox shows up with text B.

 

I tried using javascript browser detection for this but i was a whole mess, so im trying to figure out how to implement this in another more efficient way.. keep in mind i have little experiance with php so i want it to be simple and easy to work with. if anyone could help that would be sick.. thanks.

Link to comment
https://forums.phpfreaks.com/topic/204552-help-with-useragents-and-textboxs/
Share on other sites

try

 

<?php
if ( preg_match("~MSIE~isU",$_SERVER['HTTP_USER_AGENT']) ){
    print "Is internet explorer!";
}
elseif ( preg_match("~Firefox~isU",$_SERVER['HTTP_USER_AGENT']) ){
   print "Is firefox";
}
?>

 

If you want to find out the browser for design purposes better of checking what the render engine is, that way modifications of firefox still render the same.

ok but how would i go about putting the text boxes into the code.. heres one of my scripts with facebook .. the tags <fb:user-agent> is basically what i need

<fb:user-agent includes="ie 6,ie 7,ie 8"><textarea id='textcode' class='textcode' onclick='this.focus();this.select();' rows='2' cols='40'>TEXT B</textarea>
</fb:user-agent>
<fb:user-agent excludes="ie 6,ie 7,ie 8">
<textarea onclick='this.focus();this.select();' rows='2' cols='40'>
TEXT A</textarea>
</fb:user-agent>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.