Note that there are some explanatory texts on larger screens.

plurals
  1. PObackgound-image doesn't display intermittently. Google Chrome on Mac
    primarykey
    data
    text
    <p>I have a website with a div for which I set the background-image to a random image:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; #bighead {width:100%;height:500px;text-align:center;background-repeat:no-repeat;} &lt;?php $bgImages = array('main-bg-1.jpg','main-bg-2.jpg','main-bg-3.jpg','main-bg-3.jpg'); print '#bighead {background-image:url('.$bgImages[array_rand($bgImages)].');}'; ?&gt; &lt;/style&gt; &lt;link rel="stylesheet" type="text/css" href="http://sstatic.net/stackoverflow/all.css?v=2e4402f4f417"&gt; &lt;link rel="stylesheet" type="text/css" href="http://beta.images.theglobeandmail.com/bundle/gzip_106019672/css/site.v3.css" /&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="bighead"&gt; Nulla facilisi. In vel sem. Morbi id urna in diam dignissim feugiat. &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I'm hosting this little example here: <a href="http://ryan.courtnage.ca/chrome-bg-bug/" rel="nofollow">http://ryan.courtnage.ca/chrome-bg-bug/</a></p> <p>Every time you reload the page, you will get a random background image. This works great in all browsers, with the exception of Chrome on Mac.</p> <p>With Chrome on a Mac, the background image will display just fine, until you refresh a number of times. At a certain point, some of the background images will simply not display. It's intermittent.</p> <p>I think it may have something to do with the browser's cache. If I clear Chrome's cache, and start refreshing the page, I'll see the following entries in Apache's access log: </p> <pre><code>xx.xx.xxx.xxx - - [08/Mar/2011:19:53:40 +0000] "GET /chrome-bg-bug/main-bg-2.jpg HTTP/1.1" 200 31821 xx.xx.xxx.xxx - - [08/Mar/2011:19:53:52 +0000] "GET /chrome-bg-bug/main-bg-2.jpg HTTP/1.1" 304 - xx.xx.xxx.xxx - - [08/Mar/2011:19:53:52 +0000] "GET /chrome-bg-bug/main-bg-2.jpg HTTP/1.1" 304 - xx.xx.xxx.xxx - - [08/Mar/2011:19:54:06 +0000] "GET /chrome-bg-bug/main-bg-2.jpg HTTP/1.1" 304 - </code></pre> <ol> <li>200 OK is returned & the image is sent to the browser. The background image always seems to work. <li>304 Not Modified is returned. The background image displayed. <li>304 Not Modified is returned. The background image displayed. <li>304 Not Modified is returned. In this case the background image did NOT display. </ol> <p>All subsequent requests for main-bg-2.jpg, which result in 304 Not Modified, will produce the problem where the background image does not show.</p> <p>I've duplicated this problem on multiple Macs running Google Chrome. I should also mention another important point. I only seem to be able to duplicate the problem when there are sizeable stylesheet and/or js files being included in the page. So in my example above, I'm loading in jquery and stylesheets from a couple of websites (stackoverflow &amp; globaeandmail). It doesn't need to be these particular files, nor do the files need to come from an external source (I originally ran into the problem where all stylesheet &amp; js files are local).</p> <p>Does anyone have any idea why this is happening and how I might get around it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload