1

Him I'm using this script to detect browsers, but it seems to not to implementing css in opera. So, in browserdetect.js i have this:

{
  prop: window.opera,
  identity: "Opera"
},

And in my html i have this:

else if (BrowserDetect.browser == "Opera") {
    document.write ('<link href="styles/style.css" media="screen" rel="stylesheet" type="text/css" />');

It seems to be working properly in other browsers, but in Opera it just fails to implement <link href="styles/style.css" media="screen" rel="stylesheet" type="text/css" /> in head part of the page. Can you suggest what could be the problem? Thank you.

Maay
  • 575
  • 9
  • 27

3 Answers3

2

This works so you have other issues

http://jsfiddle.net/mplungjan/sWvqk/

BrowserDetect.init();  
alert("Opera? "+BrowserDetect.browser+":"+(BrowserDetect.browser=="Opera"))
mplungjan
  • 169,008
  • 28
  • 173
  • 236
0

why not use browsecap for php? this could be also good: http://www.dangrossman.info/2010/10/11/a-browscap-ini-parser-in-javascript/ or try this: how to determine the opera browser using javascript

Community
  • 1
  • 1
  • Because i really have to use only html, javascript and css. – Maay May 16 '11 at 15:54
  • your server doesnt support php and json? so your script just works if javascript is activated, the php script would be better well: http://stackoverflow.com/questions/1998293/how-to-determine-the-opera-browser-using-javascript –  May 16 '11 at 15:57
0

If your having an issue with only opera and css, why not try and edit your current css to add opera specific calls?

This code can be used to target opera only in css:

@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {

            #my-id { clear:right; }

        }

See here for more on these browser css calls

Soatl
  • 10,224
  • 28
  • 95
  • 153