xzmk07 Posted June 12, 2010 Share Posted June 12, 2010 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 More sharing options...
backie Posted June 12, 2010 Share Posted June 12, 2010 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. Link to comment https://forums.phpfreaks.com/topic/204552-help-with-useragents-and-textboxs/#findComment-1071054 Share on other sites More sharing options...
xzmk07 Posted June 12, 2010 Author Share Posted June 12, 2010 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> Link to comment https://forums.phpfreaks.com/topic/204552-help-with-useragents-and-textboxs/#findComment-1071057 Share on other sites More sharing options...
backie Posted June 12, 2010 Share Posted June 12, 2010 Well then what you do is check and see if the user agent isn't internet explorer and then print out the two textareas. Link to comment https://forums.phpfreaks.com/topic/204552-help-with-useragents-and-textboxs/#findComment-1071061 Share on other sites More sharing options...
xzmk07 Posted June 12, 2010 Author Share Posted June 12, 2010 i tried adding "<textarea> </textarea>" after the print but when i try to load the page its white Link to comment https://forums.phpfreaks.com/topic/204552-help-with-useragents-and-textboxs/#findComment-1071260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.