Use javascript to fetch content from external site

有些话、适合烂在心里 提交于 2019-12-11 17:35:41

问题


Say I there's mypage.html and otherpage.html

otherpage.html has some content <p>content is content</p>

I want a javascript that can fetch the content from otherpage.html and paste it in mypage.html

Is there a javascript that can accomplish this? thanks.


回答1:


From the title, it appears that otherpage.html is in a different domain. This being the case this is not possible in the browser (there's a few exceptions with flash/java/silverlight). If the page is in the same domain, it's easy. Take a look at jQuery.get.



来源:https://stackoverflow.com/questions/9089669/use-javascript-to-fetch-content-from-external-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!