var innerHTML =innerHTML= /ad.doubleclick.net/gm;var innerHTML= innerHTML.match( regexp );innerHTML(由regexp +regexp标记标记);console.log( innerHTML);
alert说,匹配只返回两个ad.doubleclick.net标记。我想,首先,代码不能访问整个身体,如果不放在身体很底部。但是它在div "interstitial_wrapper“中找到了两个标签,它在我的代码之后出现。
所以我的问题是:
请查看http://wap7.ru/folio/bannerstat/partners/doubleclick2.html并查看视图源代码,因为它太大了,无法在这里包含。
发布于 2012-02-21 12:10:05
您不必绑定到onload事件。只需绑定到DOMContentLoaded事件即可。
因为您已经在页面中包含了jQuery,所以可以使用.ready轻松地完成
$(document).ready(function() {
var innerHTML = document.body.innerHTML;
/* If you want to use a RegExp, use the following:
var regexp = /ad\.doubleclick\.net/gi; // Note: escaped dot
var matches = innerHTML.match(regexp);
matches = matches ? matches.length : 0; // matches can be `null`
*/
// This is more effective:
var matches = innerHTML.split('ad.doubleclick.net').length - 1;
alert('Found ' + matches + ' tags.');
console.log( innerHTML );
});https://stackoverflow.com/questions/9376805
复制相似问题