2014-05-20 65 views
0

可能在這些上下文中顯示圖像而不會主要編輯代碼。通常你有:顯示圖像而不是文本Javascript函數

(function() { 
    popupShow("Loading..."); 

使加載...在它的內部彈出一個div。可能,因爲這是HTML div指定一個圖像顯示在這個div而不是文本?原油,但看不重新寫,東西的效果manupulate:

(function() { 
    popupShow(<img src="img/video.png">); 

的JavaScript 「popupShow」

function popupShow(text, buttonText, cb) { 
    var saveBoxHeight = 60; 
    var saveBoxWidth = 380; 

    if ((typeof buttonText)!="undefined") { 
     saveBoxHeight+=30; 
    } 

    disableDiv = document.createElement('div'); 
    disableDiv.id = "DisableDiv"; 
    disableDiv.className="DisableDiv"; 
    disableDiv.style.cssText = "position:absolute; z-index: 120"; 
    disableDiv.style.width = window.document.documentElement.offsetWidth + "px"; 
    disableDiv.style.height = window.document.documentElement.offsetHeight + "px"; 

    disableDiv.style.top = "0px"; 
    disableDiv.style.left = "0px"; 

    newDiv = document.createElement('div'); 
    newDiv.id = "PopUpDiv"; 
    newDiv.className="PopUpDiv"; 
    newDiv.style.cssText = "position:fixed;background-color:white;font-size:35px;font-family:arial;border-style:groove; border-color:blue; z-index:121"; 
    newDiv.style.borderWidth = "5px"; 
    newDiv.style.width = saveBoxWidth + "px"; 
    newDiv.style.height = saveBoxHeight + "px"; 
    if ($.browser.msie) { 
     newDiv.style.top = (window.document.documentElement.offsetHeight - (saveBoxHeight*1))/2 + "px"; 
     newDiv.style.left = (window.document.documentElement.offsetWidth - (saveBoxWidth*1))/2 + "px"; 
    } else { 
     newDiv.style.top = (window.innerHeight - (saveBoxHeight*1))/2 + "px"; 
     newDiv.style.left = (window.innerWidth - (saveBoxWidth*1))/2 + "px"; 
    } 
    titleDiv = document.createElement('div'); 
    titleDiv.style.cssText = "height:25px; color:white; font-size:18px; font-family:arial; background-color:#000099; text-align:right;"; 

    center = document.createElement('center'); 
    newSpan = document.createElement('span'); 
    newSpan.id = "PopUpText"; 

    newSpan.innerHTML = text; 
    center.appendChild(newSpan); 

    newDiv.style.margin = "10px 10px 10px 10px"; 
    newDiv.style.paddingTop = "8px"; 
    newDiv.appendChild(center); 

    if ((typeof buttonText)!="undefined") { 
     button = document.createElement("input"); 
     button.type="button"; 
     button.value=buttonText; 
     button.style.cssText="position:absolute;right:10px;bottom:10px;"; 
     if (((typeof cb)!="undefined")&&(cb!=null)) { 
      button.onclick=cb; 
     } 
     newDiv.appendChild(button); 
    } 

    document.body.appendChild(newDiv); 
    document.body.appendChild(disableDiv); 
} 

回答

0

做你的周圍你的HTML img標籤嘗試過?

(function() { 
    popupShow('<img src="img/video.png">');