Get viewport Height in pixels using javescript and css

Add a “Javascript to Bubble” element to your page, from the ToolBox plugin. Give it a suffix in its property, say “h”. Then add a workflow item to run javascript on page load. In this javascript code add your code that gets the viewport height, and return it to the “Javascript to Bubble” element using bubble_fn_suffix(var).

Here’s an example (I grabbed the viewport height code off some page and have not tested it):

var viewportHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
bubble_fn_h(viewportHeight);

Now you can just use the Javascript to Bubble element’s value to get the viewport height you stored.

2 Likes