homepage Welcome to WebmasterWorld Guest from 54.196.198.213
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

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
iggy99




msg:1586603
 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

 

toadhall




msg:1586604
 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.

iggy99




msg:1586605
 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

David




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

Does this help

if (eregi("opera",$HTTP_USER_AGENT)){
$BROWSER_NAME="OPERA";
}

Then do what you need to do

iggy99




msg:1586607
 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">
<tr>
<td>this table conatins menue - opera</td>
</tr>
</table>
">' );

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

}

toadhall




msg:1586608
 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.");
}

David




msg:1586609
 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)){
$BROWSER_NAME="OPERA";
}
if ($BROWSER_NAME == "OPERA"){
?> //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.


iggy99




msg:1586610
 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:

[webshop101.com...]

iggy99




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

think - iave it -

<?php
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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved