After accepting the cookies, only a white page is displayed
This problem usually goes back to an old Google Analytics script that contains the document.write
command. The following script is the problematic integration:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
Instead of document.write
, DOM manipulation functions such as insertBefore
and appendChild
should be used. The script should therefore be adapted and could then look like this, for example:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
var script = document.createElement('script');
script.src = gaJsHost + 'google-analytics.com/ga.js';
document.head.appendChild(script);
</script>
The above code replaces the original integration with document.write
with the creation of the script
element using document.createElement
and the integration into the DOM tree using document.head.appendChild
. After replacing the code on the page, the page should no longer turn white after accepting the cookies.
Similarly, similar scripts that use document.write
to include scripts can be updated.