javascripttypo3fluid

Pass Javascript variable to TYPO3 variable


With the following JS I get the height of a div

    document.addEventListener(
        "DOMContentLoaded", () => {
          const element = document.getElementById("c27");
          let text = element.offsetHeight + "px";
          document.getElementsByTagName("divSize").??? = text;
        }

    );

Now I want to pass the variable to a fluid variable as value

<f:variable name="divSize" value="???" />

How can I do it?


Solution

  • You will have to do an HTTP request either by reloading the page and adding a URL parameter or by pushing the value to the server via AJAX and providing the value as a parameter. Then you can handle the value within that request via Fluid and return either a full page or a an HTML-snippet.