문제

I am currently writing some Javascript code that adds some tags across text in an HTML file after the page loads. I use the

window.onload

method for achieving this.

However, I am facing an issue in pages like google plus, where you get more content as you scroll down. Is there a way of calling my JS function when such a page adds more content?

Thanks

Akshay

도움이 되었습니까?

해결책

There are several ways how to get this working. You can either use jquery like this:

$('#mydiv').bind("DOMSubtreeModified",function(){
    // your code goes here
    alert('changed');
});

Note that this is not supported in IE8( and below).

Or you can run loop and continuously fire the desired code:

var interval = setInterval(function() {
    // your code goes here
}, 1000);

Fiddle: http://jsfiddle.net/8RF5r/5/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top