Question

Is it possible to have JavaScript reload only a specific div of a page and replace it with the div of the loaded page? It would be better if this only downloads the data from inside the div, but this is not necessary if it's not possible. Since this is a UserScript/GreaseMonkey script, it is purely client side. If this is possible, how can it be done?

Was it helpful?

Solution

It is not possible to request only part of the page containing the div form the server, unless the contents of the div is being loaded separately on the website.

You can use XMLHttpRequest (http://developer.mozilla.org/en/docs/XMLHttpRequest) or GM_xmlhttpRequest (http://wiki.greasespot.net/GM_xmlhttpRequest) if on another domain to request the entire page, find the element in the response content, and replace the content on the page.

The exact code you need will depend a lot on the content/website, but that should get you started.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top