全部, 我提前为这个问题的简单性道歉,我是编程的新手。我有两个函数,每个函数都会提示加载一个url。我想使用一个定时器循环让这两个函数每30秒运行一次,然后重复循环。在下面的代码中,URL加载一次,但从不初始化第二个URL。非常感谢你帮我解决这个问题!
function initializeViz1() {
var placeholderDiv = document.getElementById("tableauViz1");
var url1 = "https://public.tableausoftware.com/views/SCADA_SERVER_DASHBOARD/Dashboard1?:embed=y&:display_count=no";
var options = {
width: 2000,
height: 1200,
hideTabs: true,
hideToolbar: false,
onFirstInteractive: function () {
workbook = viz.getWorkbook();
activeSheet = workbook.getActiveSheet();
}
};
viz = new tableauSoftware.Viz(placeholderDiv, url1, options);
}
function initializeViz() {
var placeholderDiv = document.getElementById("tableauViz");
var url2 = "https://public.tableausoftware.com/views/Book1_1719/Sheet1?%3AshowVizHome=no#1";
var options = {
width: 2000,
height: 1200,
hideTabs: true,
hideToolbar: false,
onFirstInteractive: function () {
workbook = viz.getWorkbook();
activeSheet = workbook.getActiveSheet();
}
};
viz = new tableauSoftware.Viz(placeholderDiv, url2, options);
}
var counter = 0;
var i = setInterval(function () {
// do your thing
if (counter === 0) {
$(initializeViz);
} else if (counter === 1) {
$(initializeViz1);
}
counter++;
if (counter === 2) {
clearInterval(i);
}
}, 15000);
答案 0 :(得分:1)
您可以像这样使用setTimeout()
function testFunction(){
//do your thing
setTimeout(testFunction, 30000);
}
testFunction();
相关文章: Call a javascript function every 5 seconds continuously