Keith
Keith

Reputation: 938

document.write iframe causing white screen

I'm having an issue when utilizing doubleclick floodlight analytics. When a user clicks on a button, the floodlight should fire and open a new window (as it does). The problem occurs when the user goes back to the original screen and the page is white. You have to reload the page to get back to it.

HTML - clicking button opens new window and fires handleThirdFloodClick

<button role="link" target="_blank" href="URLHERE/locations" onclick="handleThirdFloodClick();">
  <span>Find A LOCATION</span>
</button>

JavaScript - doubleclick code fires when button is clicked

function handleThirdFloodClick(){
  var axel = Math.random() + "";
  var a = axel * 10000000000000;
  document.write('<iframe src="https://XXXXXXX.fls.doubleclick.net/activityi;src=XXXXXXX;type=XXXXXX;cat=XXXXXXXX;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;tfua=;npa=;ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>');
}

The two "Find a location" buttons and the $5 off button are all causing this white screen.

I am unable to reproduce the white screen using liveserver, but it shows up on a production site. Does anyone have any ideas?

Thanks

Upvotes: 0

Views: 246

Answers (2)

Brad
Brad

Reputation: 11

Just in case anyone else runs into this, it's a poor example from Google.

The problem is that ord=' + a + ' is in this is beyond me, it's an undefined variable that will break many sites because it can't be evaluated. You need to make it ord='1' and that should fix it.

But, this also points out that error trapping is not working on the site as well, so if you can fix both, that would be optimal.

Upvotes: 1

Brian Norman
Brian Norman

Reputation: 564

Do you have the 'Support document.write' box checked in your GTM tag?

Upvotes: 0

Related Questions