0

I want this part of the code NOT to execute in Safari. How to make it?

transform:'skewX(-'+$deg1+'deg) rotateX('+$deg1+'deg)', '-moz-transform': 'skewX(-'+$deg1+'deg) rotateX('+$deg1+'deg)', '-webkit-transform': 'skewX(-'+$deg1+'deg) rotateX('+$deg1+'deg)'

in code:

function sec1() {
                                $global_v=$global_v+10;                         
                                $nowz=(($global_v+$start_pr)/$skorost)+$ugol*2;
                                for (var ink=0, len = $kolvo; ink < len; ink++)
                                {
                                uno1=$(ImgDiv[ink]);
                                $rad1=((ink+1)*$ugol+$nowz);
                                $deg1=$rad1*360/(2*Math.PI)+270;
                                trata = Math.sin(-($rad1))*$size_dug+$smes_x;
                                if(trata>260){
                                zind=1;
                                }else{
                                zind=10;
                                }
                                uno1.css({top: Math.cos($rad1)*$size_dug+$smes_y, left: trata, zIndex: zind, transform:'skewX(-'+$deg1+'deg) rotateX('+$deg1+'deg)', '-moz-transform': 'skewX(-'+$deg1+'deg) rotateX('+$deg1+'deg)', '-webkit-transform': 'skewX(-'+$deg1+'deg) rotateX('+$deg1+'deg)'});
                                };  
                        }
COSTADOR
  • 309
  • 2
  • 10
  • 1
    `if safari then don't execute code` – Brad M Mar 22 '13 at 15:13
  • If you need some lines of code to be skipped in Safari, the drill is rather simple: check for Safari (with `$.browser.webkit && !window.chrome`, for example; check [this question](http://stackoverflow.com/questions/3303858/distinguish-chrome-from-safari-using-jquery-browser) for alternatives), then skip it. – raina77ow Mar 22 '13 at 15:14
  • what happens if it does execute ? – SachinGutte Mar 22 '13 at 15:15
  • http://stackoverflow.com/questions/15412186/slider-in-the-form-of-tape-bugs-in-safari – COSTADOR Mar 22 '13 at 15:16
  • Why are you checking specifically for Safari? Safari uses the Webkit rendering engine, which is also used by Chrome for example. So whatever rendering issues you have in safari, will possibly also occur in Chrome. – Justus Romijn Mar 22 '13 at 15:21
  • 1
    @raina77ow $.browser is deprecated and was removed in 1.9 – epascarello Mar 22 '13 at 15:22
  • In Chrome and Mozilla it looks good enough, but in Safari it looks terrible. jsfiddle.net/mcbgv/7/ – COSTADOR Mar 22 '13 at 15:22
  • @epascarello Hmm, didn't know that, thanks. Does it mean all browser-detection techniques are considered deprecated in jQuery? – raina77ow Mar 22 '13 at 15:24
  • I can confirm what COSTADOR says. Some rendering can turn out very different in different WebKit-based browsers. He has a point of specifically checking different WebKit browsers, instead of WebKit in general. –  Mar 22 '13 at 15:24
  • 1
    @raina77ow Read the "Spring Cleaning" section of this post: http://blog.jquery.com/2012/06/22/jquery-1-8-beta-1-see-whats-coming-and-going/ – epascarello Mar 22 '13 at 15:43

3 Answers3

2

You can try an old and browser detection technique:

var agent = navigator.userAgent.toLowerCase(); 
 if (agent.indexOf('safari')!=-1){ 
   if(agent.indexOf('chrome')  > -1){
    //execute your code this is chrome
   }else{
    // here is safari
   }
  }

But browser detection considers as a bad practice

happyCoda
  • 418
  • 2
  • 2
  • Within the `// here is safari` part, you could append a link tag to the `head`-tag to include an extra stylesheet that will rewrite certain styles to be different in Safari. –  Mar 22 '13 at 15:22
0

I guess you are already using jQuery. So i would rather go with jquery browser detection. Detect safari and write an alternative code for it.

However in my experience the browser detection is never 100% accurate. Especially when you look on mobile browsers.

Prasanna
  • 10,956
  • 2
  • 28
  • 40
0

You can comment that code line out. It works in css also.