使用javascript从外部站点获取内容

使用javascript从外部站点获取内容

本文介绍了使用javascript从外部站点获取内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有mypage.html和otherpage.html

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

otherpage.html有一些内容<p>content is content</p>

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

我想要一个可以从otherpage.html获取内容并将其粘贴到mypage.html中的javascript

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

有没有可以完成此操作的JavaScript?谢谢.

Is there a javascript that can accomplish this? thanks.

推荐答案

从标题看,似乎otherpage.html在另一个域中.在这种情况下,这在浏览器中是不可能的(flash/java/silverlight有一些例外).如果页面在同一个域中,这很容易.看看 jQuery.get .

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.

这篇关于使用javascript从外部站点获取内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 21:25