Create a data element containing scroll height of a popup

philipk92120636

06-01-2020

Hi all!

 

I want to create a data element that saves the distance a customer scrolls within a popup. I can return the value I'm after in the browser console using the following:

 

// Full height of div including scroll
var totalHeight = $("#myDialogContent")[0].scrollHeight;

// Initial height of div that needs to be subtracted
var initialHeight = $("#myDialogContent")[0].clientHeight;

// Actual element height value
var height = totalHeight - initialHeight;

// Scroll depth
var scroll = $("#myDialogContent").scrollTop();

var scrollPercentage = (scroll/height) * 100;

var rounded = Math.round(scrollPercentage);

return rounded;

 

This is the code I've used in the data element. However, when I try to return the value of the data element in the browser I get undefined each time.

 

Any help would be greatly appreciated. 

View Entire Topic

franzli

06-01-2020

Might need some more context here. What kind of popup is it? Is it a whole new window popup? If so, you will need to make sure Launch is implemented on it as well.