我有一個引用URL的基本HTML/JavaScript查詢。我不想引用單個URL,而是引用3,並讓它們在計時器上循環。引用定時器上的多個URL
例如:
目前我有URL1 = Dashboard1
,我想那裏是一個URL2 = Dashboard2
和URL3 = Dashboard3
。
這裏是我的腳本:
<html>
<head></head>
<body>
<script type="text/javascript" src="http://public.tableausoftware.com/javascripts/api/tableau_v8.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
function initializeViz() {
var placeholderDiv = document.getElementById("tableauViz");
var url1 = "http://ccapptabdev01/t/Gas/views/ERXCommissioningDashboard/Dashboard1";
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);
}
$(initializeViz);
</script>
<script type="text/javascript">
function RefreshViz(){
//alert("test");
viz.refreshDataAsync();
}
if (document.addEventListener) {
window.addEventListener("load", RefreshViz, false);
} else if (document.attachEvent) {
window.attachEvent("onload", RefreshViz);
}
setInterval(RefreshViz, 30000);
</script>
<div id="tableauViz">
</div>
</body>
</html>
謝謝!編輯我的腳本,但是在運行時它只播放三者中的第一個URL。下面是編輯的腳本:
<html>
<head></head>
<body>
<script type="text/javascript" src="http://public.tableausoftware.com/javascripts/api/tableau_v8.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
var vizs = [];
vizs.push(initializeViz('tableauViz1', "http://ccapptabdev01/t/Gas/views/SCADA_SERVER_DASHBOARD/Dashboard1"));
vizs.push(initializeViz('tableauViz2', "http://ccapptabdev01/t/Gas/views/ERXTrendingTool/Dashboard1"));
vizs.push(initializeViz('tableauViz3', "http://ccapptabdev01/t/Gas/views/ERXTrendingTool/Dashboard1"));
function initializeViz(div, url) {
var placeholderDiv = document.getElementById(div);
var options = {
width: 2000,
height: 1200,
hideTabs: true,
hideToolbar: false,
onFirstInteractive: function() {
workbook = viz.getWorkbook();
activeSheet = workbook.getActiveSheet();
}
};
return {div: placeholderDiv, vis: new tableauSoftware.Viz(placeholderDiv, url, options)};
}
</script>
<script type="text/javascript">
var visible = 0; //0, 1 or 2 - maintains state
function rotate() {
visible++;
if (visible+1 > vizs.length()) {
visible = 0;
}
//hide all
vizs.forEach(function(vis, index, array) {
vis.placeholderDiv.style.display === 'none';
});
//show and update
vizs[visible].placeholderDiv.style.display = 'block';
vizs[visible].viz.refreshDataAsync();
}
setInterval(rotate, 15000);
</script>
<div id="tableauViz1">
</div>
<div id="tableauViz2" style="display:none;">
</div>
<div id="tableauViz3" style="display:none;">
</div>
</body>
</html>
其他編輯:
<html>
<head></head>
<body>
<script type="text/javascript" src="http://public.tableausoftware.com/javascripts/api/tableau_v8.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
var vizs = [];
vizs.push(initializeViz('tableauViz1', "http://ccapptabdev01/t/Gas/views/SCADA_SERVER_DASHBOARD/Dashboard1"));
vizs.push(initializeViz('tableauViz2', "http://ccapptabdev01/t/Gas/views/ERXTrendingTool/Dashboard1"));
vizs.push(initializeViz('tableauViz3', "http://ccapptabdev01/t/Gas/views/ERXTrendingTool/Dashboard1"));
function initializeViz(div, url) {
var placeholderDiv = document.getElementById(div);
var options = {
width: 2000,
height: 1200,
hideTabs: true,
hideToolbar: false,
onFirstInteractive: function() {
workbook = viz.getWorkbook();
activeSheet = workbook.getActiveSheet();
}
};
return {div: placeholderDiv, viz: new tableauSoftware.Viz(placeholderDiv, url, options)};
}
</script>
<script type="text/javascript">
var visible = 0; //0, 1 or 2 - maintains state
function rotate() {
visible++;
if (visible+1 > vizs.length()) {
visible = 0;
}
//hide all
vizs.forEach(function(viz, index, array) {
viz.placeholderDiv.style.display === 'none';
});
//show and update
vizs[visible].placeholderDiv.style.display = 'block';
vizs[visible].viz.refreshDataAsync();
}
setInterval(rotate, 15000);
</script>
<div id="tableauViz1">
</div>
<div id="tableauViz2" style="display:none;">
</div>
<div id="tableauViz3" style="display:none;">
</div>
</body>
</html>
查看上面的最新編輯 – Calbruin 2015-03-31 20:23:47