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 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.
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 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.
Share Improve this question edited Dec 6, 2021 at 8:35 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Dec 6, 2010 at 18:35 PixelPerfect3PixelPerfect3 1101 gold badge1 silver badge6 bronze badges 3- If you're writing a browser extension, you should probably note that fact. If not, then I'm pretty confused about where your script is used. – Pointy Commented Dec 6, 2010 at 18:43
- Ah yes sorry...I am writing a browser extension. – PixelPerfect3 Commented Dec 6, 2010 at 18:44
- Not quite sure what you are trying to do. For detecting mutation events, jQuery mutation events discussion. Doesn’t look straightforward. – Benji XVI Commented Dec 6, 2010 at 18:48
1 Answer
Reset to default 3use .live() ?
$(document).ready(function()
{
$(document).live("onchange",function()
{
// blah?
});
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742300101a4417874.html
评论列表(0条)