- I have page with many doubleclick scripts
-
I have js code inserted at the body top (via s.src=(‘parts_async_dev.js’)):
var innerHTML = document.getElementsByTagName('html')[0].innerHTML.toString(); var regexp = /ad.doubleclick.net/gm; var matches = innerHTML.match(regexp); alert('found ' + matches.length + ' tags by regexp ' + regexp); console.log( innerHTML);
alert says that matches returns only 2 of ad.doubleclick.net tags.
I thought first that code can not access whole body if not placed at the body very bottom.
But it finds 2 tags inside div “interstitial_wrapper” which comes after my code.
So my questions are:
- why is it so
- How to access whole body form body start ( i may not use body ‘onload’ event. it is required to use script asap)
Please take a look at http://wap7.ru/folio/bannerstat/partners/doubleclick2.html
and see view source, because it is too large to include here.
You don’t have to bind to the onload event. Just bind to the
DOMContentLoadedevent.Since you’ve already included jQuery in your page, this can esily be done using
.ready: