2016-09-21 30 views
0

我想在我的網站打開自定義彈出窗口。但是,它不適用於Safari。自定義彈出不在Safari上打開

這是我怎麼稱呼它:

<img id="product-1" class="product-box" src="images/image.jpg" onclick="openProduct(1)">

openProduct()做到這一點:

function openProduct(id){ 
    activeID=id; 
    openPopup(); 
    fillPopupContent(id); 
} 
function openPopup(){ 
    document.getElementById("popup").style="opacity:1;z-index:1000"; 
} 

它適用於任何其他瀏覽器非常好,但不是在Safari瀏覽器。

在該函數中添加一個alert();表明它調用成功的函數。但是,我看不到彈出窗口。

如果你們有任何建議...

回答

0

style屬性應該返回CSSStyleDeclaration對象,它包含的樣式鍵/值。

爲什麼它工作在其他瀏覽器似乎很奇怪,因爲你正在使用的語法是錯誤的,它應該是

function openPopup(){ 
    var popup = document.getElementById("popup"); 

    popup.style.opacity = "1"; 
    popup.style.zIndex = "1000"; 
} 
+0

**它的工作原理!謝謝!** – Luca

+0

不客氣! – adeneo