Tracking visibillity of an element without jQuerry

Gold Contributor
Gold Contributor

Hi

I'm trying to track an event based on visibility of an elemen inside a iframe.

there is no jquerry on the site. so far i've tried a couple of differet aproaches.

And this is the one thats closest to working.

	poll = window.setInterval(function()
{
    var current_style = window.frames[0].document.getElementById("nyhetsbrevSuccess").style.display;
    if (current_style != "none") {
         window.clearInterval(poll);
		 console.log("test");
			utag.link( {
				"success" : "test"
   				 }
					);
        
    } else {
        previous_style = current_style;
    }
}, 500);

the code workes fine and prints "test" to the console once when the element changes style from "none". But the utag.link goes berserk and sends as many calls it can, as fast as it can.

Any of you guys know how i could do this?

2 REPLIES 2

Tracking visibillity of an element without jQuerry

Gold Contributor
Gold Contributor

found the problem

It was jus me being an idiot.

I had an other javascript extention that picked up the change aswell and then we startet looping

Tracking visibillity of an element without jQuerry

Employee Emeritus

Great job at figuring out the problem @Bknapstad!

Remember to give me a kudo if you like my post! Accepting my post as a solution is even better! Also remember that search is your friend.
Public