javascript
  • jquery
  • 2013-06-26 70 views 0 likes 
    0

    我正試圖在預加載時加載圖像。它在IE和Firefox上運行良好,但不適用於Chrome。我只是這樣做:預加載圖像在Chrome中不工作

    var t1 = "<div id='waiting' style='filter:alpha(opacity=50); z-index:9990; position:fixed; width: 100%; height: 100%; left: 0px; top: 0px; visibility: visible; opacity: 0.5; background-color:white;'>"; 
        t1 += "<img src='img/loader_36.gif' alt='waiting' style='z-index:9999; position:fixed; top:40%; left:45%;width:36px; height:36px;' /></div>"; 
        $('body').append(t1); 
    

    任何想法?

    回答

    0
    var t1 = "<div id='waiting' style='filter:alpha(opacity=50); z-index:9990; position:fixed; width: 100%; height: 100%; left: 0px; top: 0px; visibility: visible; opacity: 0.5; background-color:white;'>"; 
    t1 += "<img src='http://lorempixel.com/400/200' alt='waiting' style='z-index:9999; position:fixed; top:40%; left:45%;width:36px; height:36px;' /></div>"; 
    $('body').append(t1); 
    

    jsfiddle測試,它適用於Chrome

    1. 你用什麼版本的jQuery的罰款?
    2. 鉻版?
    3. 是正確的圖像src在鉻?
    +0

    是的,它工作在這種情況下很好,但我說的預加載... 我的問題是一樣的HTTP將這個代碼的頁面。 com/questions/5355133/pre-loaded-images-not-display-in-chrome – Rahul

    +0

    那麼爲什麼不使用相同的解決方案呢?您不應該使用dom插入作爲預加載 –

    0

    使未加載的圖像的對象。 //計算器:

    var _myImage = new Image(400,200) //height and width of the image 
    _myImage.src = "http://lorempixel.com/400/200"; // image source (path) 
    

    要使用

    相關問題