Website should have same background color as video

2019-09-05 15:59发布

问题:

I have a website, with a HTML5-video. The website should have the same background color as the video, so I have set the website's background to the same HEX-Code as the video's. This looks fine in Chrome, but in Safari the video has a other background color as the website, which looks ugly. What can I do? Thanks!

Screenshot from Chrome, as it should be

Screenshot from Safari, as it shouldn't be

回答1:

Could you please try the following:

function BrowserDetection() {
    if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) {
                     $(body).css("background-color":"grey");   
                    }
    }

You can probably find the right color HEX-Code, make sure this line is the last in line in your .js file and make your sure your .js file is loaded in after your .css file so that the cod overwrites your css if the browser is safari

source: http://forums.asp.net/t/1965754.aspx?Determine+the+browser+using+Javascript+JQuery

if the code above doesn't work the following may:

if ( $.browser.webkit ) {
    $(body).css("background-color":"grey"); 
  }

however the code above is deprecated in jquery 1.9 and above.