如何基于POPUP可见性执行代码

时间:2018-08-30 15:12:05

标签: javascript popup

我的表中有3行,其ID如下:

listdefintion421_1_41-rowse10;
listdefintion421_1_41-rowsel2;
listdefintion421_1_41-rowsel3;

和具有以下ID的按钮:buttonZrd8UldL24I31BcWSIkSiW_36

当我在控制台中执行此命令时:

var btn1 = document.getElementById('listdefintion421_1_41-rowsel0'); 
btn1.click();
var okBtn = document.getElementById('buttonZrd8UldL24I31BcWSIkSiW_36'); 
okBtn.click();

出现以下弹出窗口,可见性可见:

var popupVisibility= document.getElementById("sap-ui-blocklayer-popup").style.visibility;

是否可以自动执行以下逻辑?

//Ok btn
var okBtn = document.getElementById('buttonZrd8UldL24I31BcWSIkSiW_36');
//Popup 
var popupVisibility= document.getElementById("sap-ui-blocklayer-popup").style.visibility;

//This will click on row1 
var btn1 = document.getElementById('listdefintion421_1_41-rowsel0'); 
btn1.click();

//Click the ok Btn
okBtn.click();


/* I'm sutck here */
//I want when popupVisibility change from visible to hidden, the below code should execute


//This will click on row2
var btn2 = document.getElementById('listdefintion421_1_41-rowsel2'); 
btn2.click();

//Click the ok Btn
okBtn.click();


/* I'm sutck here */
//Again, when popupVisibility change from visible to hidden the below code should execute 

var btn3 = document.getElementById('listdefintion421_1_41-rowsel3'); 
btn3.click();

//Click the ok Btn
okBtn.click();

更新

到目前为止,我已经提出了:

var RowIds = [ "2", "3","4","5","7","9"];




function funcE(i) {

 var rowBtn= document.getElementById('listdefintion421_1_41-rowsel'+i);
 rowBtn.click(); 
 var btnok = document.getElementById('buttonZrd8UldL24I31BcWSIkSiW_36');
 btnok.click();

}


for( var i=0 ; i< RowIds.length ; i++)
{

    funcE(RowIds[i]);
     var visibility = document.getElementById("sap-ui-blocklayer-popup").style.visibility;
    while(visibility == "visible")
    {

      visibility = document.getElementById("sap-ui-blocklayer-popup").style.visibility;
    }

一旦弹出窗口从可见更改为隐藏,是否可以增加i值?

1 个答案:

答案 0 :(得分:0)

一种可能的方法是创建一个Intervall来检查弹出窗口的可见性。如果可见,Intervall可以执行您的回调函数,这将触发下一行脚本。