all,
Our client has doubleclick script added in the head of the web page like below,
<head>
...
<script type="text/javascript">
var axel = Math.random() + "";
var a = axel * 10000000000000;
document.write('<iframe src="https://....doubleclick.net/activityi;src=...;...ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>');
</script>
</head>
And after add the setTimeout(function(){}) as below:
<head>
...
<script type="text/javascript">
var delay=10000;
setTimeout(function(){
var axel = Math.random() + "";
var a = axel * 10000000000000;
document.write('<iframe src="https://....doubleclick.net/activityi...ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>');
},delay)
</script>
</head>
The web page refresh, but gives a blank web page. I read the post here and here, and it seems document.write wipes out the page after a delay reload, and then come out to use the solution as below:
<head>
...
<script>
setTimeout(function(){
var iframe = document.createElement('iframe');
var axel = Math.random() + "";
var a = axel * 10000000000000;
iframe.src = 'https://....doubleclick.net/activityi;...ord=' + a + '?';
iframe.width = 1;
iframe.height = 1;
iframe.frameborder = 0;
var ref = document.getElementsByTagName('script')[0];
ref.parentNode.insertBefore(iframe, ref);
}, delay)
</script>
</head>
As I not sure whether it is correct to use parentNode as above and replace the code like this, can any one help to check? Thanks very much
`, and secondly: why is there a variable being added to this scripts _before_ the `?` argument delimiter of a URL and why is it so randomised (and why is it converted to a string using `+ ''` = that seems wrong)?
– somethinghere Oct 12 '15 at 11:26`. The variable _does not_ look like 'default' doubleclick code, tbh. Try to get the original code back from doubleclick or ask around if anyone has the script you need, and simply paste that before your closing body, as traditional.
– somethinghere Oct 12 '15 at 11:48