开发者

Javascript code to detect any page changes? (maybe via AJAX)

开发者 https://www.devze.com 2023-01-29 07:30 出处:网络
I\'m new to writing Javascript, and here\'s what I\'m doing/trying to do. When a page loads (window.onload) my Javascript code goes through all the forms in a page and attaches a certain onchange meth

I'm new to writing Javascript, and here's what I'm doing/trying to do.

When a page loads (window.onload) my Javascript code goes through all the forms in a page and attaches a certain onchange method to them. This works fine for most websites on the internet, except when a page dynamically updates to load more forms on the page. How do I detect such an event and re-run my function?

For example:

The Facebook Newsfeed has a bunch of forms associated with all the different statuses/links posted. My code goes 开发者_StackOverflow中文版through them and attaches the listener. But if go you all the way down the page automatically updates to reveal more statuses/links/etc. (or you click the "Older Posts" link) - but now my javascript code has not run globally again.

Anyway I can do that?

EDIT: I am writing a browser extension.


use .live() ?

$(document).ready(function()
{
    $(document).live("onchange",function()
    {
        // blah?
    });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号