homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Browsers / Opera Browser Usage and Support
Forum Library, Charter, Moderator: open

Opera Browser Usage and Support Forum

opera - browser sniffing - replace content - help needed
in a *.php page - need to serve browser specific content

 7:29 pm on Apr 19, 2002 (gmt 0)

we have a menue on our site that uses layers - this menue does not work on 'opera' browsers

our goal - some how serve an 'opera' specific portion of the php header file that holds the menue -

any ideas how we could do this *.php page specific without using htaccess redirect?

many thanks

Back to top



 7:42 pm on Apr 19, 2002 (gmt 0)

There's a javascrpt Opera sniffer here:
[webmasterworld.com ]
Scroll to the middle of the page.

Watch the "pipes" in the code.


 7:48 pm on Apr 19, 2002 (gmt 0)

thanks - toadhall - not looking for general sniffer

but i am looking for some sort of php code i can incorporate into he my php header file containing the offending menue that will simply serve the different menues within the same page, one opera specific - server side from the php app -

many thanks


 8:03 pm on Apr 19, 2002 (gmt 0)

Does this help

if (eregi("opera",$HTTP_USER_AGENT)){

Then do what you need to do


 9:06 pm on Apr 19, 2002 (gmt 0)

not sure - this what i have been working with:

var sBrowser = "" + Request.ServerVariables ( 'HTTP_USER_AGENT' );

if ( -1 == sBrowser.indexOf ( 'Mozilla' ) )
// an unknown browser - probably opera
Out ( '<table width="90%" border="0" cellspacing="0" cellpadding="0">
<td>this table conatins menue - opera</td>
">' );

else {
// a browser - mozilla
Out ( '<<tr>
<td>this table conatins menue -non opera</td>
</table>">' );



 9:40 pm on Apr 19, 2002 (gmt 0)

Even when spoofed "Opera" will show up in the UA...

Mozilla/3.0 (Windows 98; U) Opera 6.0 [en]
Mozilla/4.76 (Windows 98; U) Opera 6.0 [en]
Mozilla/5.0 (Windows 98; U) Opera 6.0 [en]
Opera/6.0 (Windows 98; U) [en]

...so David's solution looks good, or here's another:

$UA = getenv(HTTP_USER_AGENT);
if (strstr($UA,"Opera")) {
echo ("You're using Opera.");


 9:40 pm on Apr 19, 2002 (gmt 0)

I am not sure I understand what you are working with.

If this is a parsed php page

<? //Start php mode
if (eregi("opera",$HTTP_USER_AGENT)){
?> //escape php for html
<td> Your Opera Menu </td>
<? //finish the if statement

What this does is searches the nix server variable for the user agent and if Opera is in that string it assigns OPERA to $BROWSER_NAME

Then you would check $BROWSER_NAME for Opera and if its true insert your menu. If you are on a windows box then maybe the server variable is different.


 10:01 pm on Apr 19, 2002 (gmt 0)

david, thanks -

i am unix - running an app called phpshop.org

i have stubmled through coding with alot of help from the phpshop group but this menue thing has me stuck ---

i will take a look at your info and try it out --

the offending url:



 10:53 pm on Apr 19, 2002 (gmt 0)

think - iave it -

if (!(strpos($HTTP_USER_AGENT,'Opera') === false)) {
echo("<!-- Opera 6 specific code -->");
} else {
echo("<!-- Code for other browsersvvvv -->");

Global Options:
 top home search open messages active posts  

Home / Forums Index / Browsers / Opera Browser Usage and Support
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved