js: Load html of a page from a different domain

后端 未结 3 1437
余生分开走
余生分开走 2021-01-07 12:16

I was wondering how can I load HTML, which is hosted on a different domain?

I am using JavaScript, and want to create a bookmarklet that will enable me to parse the

3条回答
  •  一生所求
    2021-01-07 13:00

    If you don't own the other page, it'll be very difficult.

    In fact, you can't make a request to another domain in javascript. The only thing you can do is load a script from another domain:

    
    

    If the purpose of this is to load data from the other domain, and (as I said) you own the other site, you can create the script.js file, which will load the data you need in your original site.

    Remember this is a delicate thing, and should be done only if you know what there will be in the script.

提交回复
热议问题