1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Detect Opera mini browser by css ??

Discussion in 'CSS' started by rontdu, Dec 13, 2009.

  1. #1
    Dear all,
    i use different css for different browser. For that i use this code:
    ------------------
    <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="iespecific.css" />
    <![endif]-->
    ------------------
    to detect is it IE? but i don't find anything to detect opera mini.
    So if anyone know the things then please help me to send the code.

    Thanks
    :D:eek::D
     
    rontdu, Dec 13, 2009 IP
  2. aquilax

    aquilax Member

    Messages:
    126
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    33
    #2
    You must use the user agent to identify Opera Mini and this cannot be done with HTML clauses.
     
    aquilax, Dec 13, 2009 IP
  3. vinpkl

    vinpkl Active Member

    Messages:
    899
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #3
    you can detect it with javascript

    vineet
     
    vinpkl, Dec 13, 2009 IP
  4. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #4
    There are only rare instances where conditional comments are desirable, but at least it has the good manners to rely on capabilities rather than sniffing.

    True. The user agent itself decides which stylesheet link to use.

    This is absolutely the least good method. Browsers, most anyway, can have their identity strings changed. Good examples are all those Opera, Firefox, and Safari browsers which identify themselves as IE because of really stupid sites that think only IE should be used at their pages.

    If a browser needs a stylesheet for mobile devices, it will download the handheld media version. See http://www.w3.org/TR/html4/present/styles.html#media-types

    cheers,

    gary
     
    kk5st, Dec 14, 2009 IP
  5. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #5
    One wishes. In fact, user agents actually decide which stylesheet of yours to use, and unfortunately some mobiles choose to use the screen stylesheet because the vendors felt users were getting short-changed with less-graphixy stylesheets.

    So some mobiles will choose the mobile stylesheet, some will choose the screen stylesheet, and a few silly machines will choose both (the first one loads and then the second modifies, as if both stylesheets targeted the same media sort).

    For this reason, I just say to hell with wasting my time making mobile stylesheets. If mobiles actually used them I'd make them.

    If your site is targeted to mobiles, then make a mobile stylesheet, and try to make your screen stylesheet as similar as possibly to the mobile one (or vice-versa) and make sure they're both pretty mobile-friendly: not too many scripts or too many graphics, and maybe not 1200px wide either would help : ). Scripts drain the hell out of batteries, and then there are still the ones who don't support scripts at all. Same goes for Flash.

    Opera Mini, I would totally not be surprised if I heard it used the regular screen stylesheet. I know it certainly CAN, as I've visited sites I've built with the demo and on one phone, and because of its zooming feature it doesn't have a problem with site width.

    That aside, any dirty CSS hacks who target Opera in general should target the Mini.
     
    Stomme poes, Dec 15, 2009 IP
  6. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #6
    That's the point, isn't it? If the UA wants/needs a special style sheet, it will ask for it. Otherwise, not.

    cheers,

    gary
     
    kk5st, Dec 15, 2009 IP
  7. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ^if it's a capable browser (like Opera Mini seems to be) then it's not a problem. But they don't all do the zooming thing well. Then some site built for desktops with wide screens is all scrolling hell for the hapless dude whose phone decides to ignore the special stylesheet written just so hapless dude doesn't need to scroll all over the place just to read a single sentence. : )
     
    Stomme poes, Dec 16, 2009 IP
  8. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #8
    Is it really the mobile device, or the web page causing the problem? I've pretty well abandoned the use of handheld media stylesheets as unnecessary; my testing, though, is admittedly incomplete. Anecdotally, no one has complained to me about their handhelds not rendering the pages usably. That's not to say they haven't been bit^H^H^H complaining — just not to me.

    Can you provide an examples list of bad devices and web pages?

    cheers,

    gary
     
    kk5st, Dec 16, 2009 IP
  9. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Since I'm personally allergic to mobiles myself (there's an old one in a drawer somewhere I think), I can only tell you what I've brought up on teh googles over which particular mobile/browsers seem to ignore the handheld stylesheet entirely, whether the main site is built with mobiles in mind or not.
    Reads both screen and handheld:
    IEMobile 6 and 8... dunno about 5
    Nokia S40
    Blazer for Palm

    Reads screen only:
    IEMobile 7
    Teleqa Q7
    Nokia S60 (my husband has a Nokia but I dunno which browser it came with)

    I would assume it's a bad combination of both. Apparently sites at 1024 or greater who require scrolling are still being encouraged ("Because nobody uses those 600 x 800 screens anymore" bah). Those are a pain for any browser set smaller than their beloved width of course. Any mobiles who don't have a zoomy feature get lots of scrolling just because (these who have zoomy features seem to be called "full web" browsers like the Mini and they seem to deal with regular stylsheets ok).

    There's another way to tell (some) mobiles that there is a handheld stylesheet and to use that use Media Queries but the only one I know for sure does it is Safari/iPhone. I have a bigger allergy to the iPhone. Anything that's as trendy as an Apple product invariably is, is too hip for me.

    Any mobile who chooses to ignore my handheld sheet, lovingly created so Hapless Dude can easily navigate my site, who ALSO chooses to act like a screen magnifyer, showing only tiny portions of my page, doesn't deserve my time making a handheld sheet in the first place.

    Basically I just read some statistics somewhere stating how there's a good group of mobiles who ignore the handheld stylesheet and I was like, screw this, and left : ) You know how lazy I am.
     
    Stomme poes, Dec 17, 2009 IP
  10. henrix343

    henrix343 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #10
    OK. So where is this script to detect that user is using Opera Mobile and give him different css sheet for example ?
     
    henrix343, Nov 13, 2015 IP
  11. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #11
    OK. So why the **** are you bouncing a six year old thread about something that shouldn't be done in the first damned place, PARTICULARLY now that responsive layout and capabilities detection are THE way of doing things?
     
    deathshadow, Nov 16, 2015 IP
  12. henrix343

    henrix343 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #12
    @deathshadow right, but what to do with retro sites? I need a script to detect opera mini and if so, give it an additional stylesheet. IE is easy with <!--[if lt IE X]> but how about opera mini specific data send to a user by their servers?

    Anyway not all modern responsive layout systems give an user option to target specific browser, this option even in a modern CMS is often not supported (if block is in the frontend, not in the cms backend - explain how you want to use it in an conditional block in your cms templates, pages, stylesheets, and modules, etc.) there are some - like http://docs.pagelines.com/tutorials/browser-specific-css (Full List of Browser/Device Classes) but it's miniority and I need to support old page without rebuild the whole site.

    I often use bootstrap/modernizr and there is no problem but in this situation working js would be huge help.
     
    henrix343, Nov 19, 2015 IP
  13. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #13
    Well, for starters, Mini doesn't DO JS. If the page doesn't "gracefully degrade" scripting off, it's quite likely broken on mini though they DO try their best to implement what they can. This is because mini pages are rendered on Opera's servers and basically sent as JPEG to the client.

    IF you used semantic markup, have proper fallbacks for the various CSS3 things that don't work and/or don't care "oh noes, they're getting a flat colour instead of a gradient" and bother using semi-fluid elastic responsive design, there is NO legitimate reason -- even in Opera Mini since around version 9, to be dicking around trying to "detect" it, PARTICULARLY with scripting.

    Not only is the methodology being asked about broken, the question itself is in fact gibberish!

    As to "supporting an old page" -- dimes to dollars it wasn't built right in the first place if this is even an issue in the first place. Suck it up and drag it kicking and screaming out of the 1990's -- while not letting "modern" idiocy like bootcrap or HTML 5's ALLEGEDLY semantic structural tags then send it back to the worst of pre-strict development practices.

    Sometimes with outdated garbage, sometimes all you can do is put a bullet in it's head, as silver-bullet fixes will kill it either way.
     
    deathshadow, Nov 19, 2015 IP
  14. henrix343

    henrix343 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #14
    ahhaha @deathshadow this is almost exactly what I did say to the client... without much success. More or less I need make this page Opera mini aware in near future. If somebody has a 'clean' and working idea I will be glad to hear.

    I really like to start project from scrap if it's outdated piece of code. But It's not me who decide about everything :(
     
    henrix343, Nov 21, 2015 IP
  15. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #15
    Ah, the "backed into a corner by the cleint" routine.

    Well, Opera Mini is different from most browsers as it's rendered on Opera's servers and then sent in a compressed rendered format (basically a glorified jpeg with a image map on it -- not joking) to the client. The renderer they use I believe is still based on an older version of Presto.

    As it's not rendered by the client, and Opera actively tried to make it so you could NOT tell it apart from desktop versions that can be kind of hard to detect. I think it even BS' the user-agent string to report itself as a desktop version... Though that's where I'd start looking if I had to do it, is the UA string. You'd have to work it server-side instead of client-side since what scripting does and does not work in Mini is extremely hit or miss. (there's a reason last I knew facebook doesn't work in mini at ALL)

    Can I assume you've set up a copy under desktop Java via an emulator for testing? That would be the first step.
     
    deathshadow, Nov 22, 2015 IP