1 Reply Latest reply on Nov 1, 2019 7:38 AM by frederic.spielmann.0

    Disable Clickjack for Tableau Online

    Chelsea Wilson

      I'm learning to use Tableau Javascript API and I'm working on embedding multiple dashboards into a website at the same div location depending on what dropdown the user chooses. The first Viz loads just fine but when I try to navigate to the second I get the following error: "Refused to display 'https://us-east-1.online.tableau.com/#/site/<MY COMPANY>/views/WeeklyReview_DEV/Guest?:size=1280,159&:embed=y&:showVizHome=n… ' in a frame because it set 'X-Frame-Options' to 'sameorigin'." I think this has to do with how Tableau handles Clickjacking prevention but I can't find anything about how to handle it on Tableau Online, just server.

       

      Code:

       

          var viz

       

          //Called after button click to change viz

          function clearViz(link,vizLocation){

              console.log('Viz Cleared');

              viz.dispose();

              var url;

              var vizLocation;

              switch (link) {

                  case 'guest':

                  url = "https://us-east-1.online.tableau.com/#/site/<MY COMPANY>/views/WeeklyReview_DEV/Guest"

                  vizLocation = "guestViz"

                  break;

              }

              console.log(url);

              initializeViz(url,vizLocation)

          }

       

           //initialize the first viz

          function initializeViz(url="https://us-east-1.online.tableau.com/t/<MY COMPANY>/views/WeeklyReview_DEV/MarketShare",vizLocation="marketViz") {

            var placeholderDiv = document.getElementById(vizLocation);

            var options = {

              // width: placeholderDiv.offsetWidth,

              // height: placeholderDiv.offsetHeight,

              embed: true,

              hideTabs: true,

              hideToolbar: true,

              onFirstInteractive: function () {

                  document.getElementById('getData').disabled = false; // Enable our button

              }

            };

            viz = new tableau.Viz(placeholderDiv, url, options);

            console.log(viz);

          }

         

          initializeViz();