Jump to content

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.