Reputation: 738
Why does my code break when I change the URL in the Tableau sample from https://help.tableau.com/current/api/js_api/en-us/JavaScriptAPI/js_api_sample_basic_embed.htm to the below URL? https://public.tableau.com/profile/david.walls2745#!/vizhome/OlderWorkers_15998328862500/Dashboard1
ie. this works:
```
<!DOCTYPE html>
<html>
<head>
<title>Basic Embed</title>
<script type="text/javascript"
src="https://public.tableau.com/javascripts/api/tableau-2.min.js"></script>
<script type="text/javascript">
function initViz(){var containerDiv = document.getElementById("vizContainer"),
url = "http://public.tableau.com/views/RegionalSampleWorkbook/Storms",
options = {hideTabs: true, onFirstInteractive: function(){console.log("Run this code when the
viz has finished loading."); } }; var viz = new tableau.Viz(containerDiv, url, options);}
</script>
</head>
<body onload="initViz();">
<div id="vizContainer" style="width:800px; height:700px;"></div>
</body>
</html>
```
and this doesn't:
```
<!DOCTYPE html>
<html>
<head>
<title>Basic Embed</title>
<script type="text/javascript"
src="https://public.tableau.com/javascripts/api/tableau-2.min.js"></script>
<script type="text/javascript">
function initViz() {var containerDiv = document.getElementById("vizContainer"),
url ="https://public.tableau.com/profile/david.walls2745#!/vizhome/OlderWorkers_15998328862500/Dashboard1",
options = { hideTabs: true, onFirstInteractive:function(){console.log("Run this code when
the viz has finished loading."); } };var viz = new tableau.Viz(containerDiv, url, options);}
</script>
</head>
<body onload="initViz();">
<div id="vizContainer" style="width:800px; height:700px;"></div>
</body>
</html>
```
Upvotes: 0
Views: 85
Reputation: 191
The format for URLs you need when embedding is different than what you see in your browser's address bar. The URL you should use for that viz is https://public.tableau.com/views/OlderWorkers_15998328862500/Dashboard1
. You can get this URL by copying the link from the Share button.
Upvotes: 1