Retrieving the entire html with external js/css/images through javascript -


I already have a javascript file (doing some functions), which will be combined with a webpage Now I want Javascript to collect the entire webpage with my HTML tags, images, external javascript files and external CSS files. I do not want to use Jquery / any other external library here.

My purpose is to get the whole webpage, save it, and show it as the original one.

Is this possible with Javascript?

Any help would be greatly appreciated.

short answer - no

No, not possible with javascript, especially Because the "savings" part, because JavaScript does not have the right to access the file in the browser environment (which we believe here), when browser extensions are developed or when explicitly modifying the security of your browser. a quality.


Long answer - If you are required: Long and winding road ...

Correct content is loading

You have to find out first .

Loading the resource

Then you have to repeat all the elements of the DOM, and all external resources must be received (which are referenced in CSS files).

You probably need to use HTML or plain-text mime-type for all resources in your requests, otherwise your browser can turn on view download with end-user popup, and not at all Download your transparent.

Updating al L References

Next you need to know how you want to organize your "downloaded" content, and where to place resources and conflict How to give her name to avoid

Once done, you need to repeat all the domed elements and update references to the use of the path of your local resources rather than your local resources.

Writing content to disk

Now the last bit is to save all these resources to disk, either by using your browser's custom API or.


Be the dragon here

None of these guarantees what you want As some pages may still contain code that will not behave well after downloading this way. Remote URLs may contain content request codes or handle some directory structures and endpoint or use resource names that you can modify ... (this would be strange, but this is not uncommon).

Comments