문제

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?

도움이 되었습니까?

해결책

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.

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