模態示例網站示例:「http://vodkabears.github.io/remodal/#modal」,目標是識別網站是否打開模式窗口。有沒有使用java腳本來達到目標的方法?在javascript中檢測模態對話框
注意:我想檢測模態窗口而不是預警/彈出窗口,而無需事先了解模態窗口「ID」或任何屬性。
模態示例網站示例:「http://vodkabears.github.io/remodal/#modal」,目標是識別網站是否打開模式窗口。有沒有使用java腳本來達到目標的方法?在javascript中檢測模態對話框
注意:我想檢測模態窗口而不是預警/彈出窗口,而無需事先了解模態窗口「ID」或任何屬性。
一個超級簡單的方法(在你的情況下)可能只是爲了檢查:
if ($('.remodal-is-opened') !== undefined) {
//open!
}
但更好的方法是按照API可以調用inst.getState();
代替:
var inst = $('[data-remodal-id=modal]').remodal();
/**
* Opens the modal window
*/
inst.open();
/**
* Returns a current state of the modal
* @returns {'closed'|'closing'|'opened'|'opening'}
*/
inst.getState();
簡單試試這個代碼
if($('.remodal-is-opened')){
console.log("modal open")
}else console.log("modal closed");
爲什麼你想要它? –
你已經寫了一些代碼嗎?我的意思是你有基地嗎? – bash0ne