问题
I am trying to find a way to include part of another website in my website.
can i do this - im thinking may use an iframe but how can i make it only show say one on the other site.
for example, if the other site has:
<div id="a_div">
content here
</div>
<div id="b_div">
other content here
</div>
how can i include only the *a_div* div on my site so only:
content here
will display?
回答1:
You can't do what you're trying to do, sorry, It's not possible to filter the iframe content.
回答2:
You can't, there is no way to filter the iframe content.
For security reasons it also isn't possible to read the contents of the iframe and then filter it to only show the section you want.
In order to achieve this you need to create a server side script that scrapes the other website and returns what you need.
回答3:
You can use iframe tag
and append id of div with #
in url:
<iframe src="http://www.yoursite.com/page.html#a_div"></iframe>
It would focus the particular section but it is not possible to filter the content only if site you are showing in iframe allows you to get that specific part.
回答4:
It's not possible to filter the content of your frame.
But it's possible to use curl php method to get a part of your website and modify like you want with parsing method.
http://davidwalsh.name/curl-download
回答5:
if the website you are trying to display in the iframe is on the same domain as yours you can filter out just a section you need...else you can't access data cross-domain.
回答6:
It is possible if you have access to the server the other website in question is running on. Then you could enable cross-origin resource sharing (cors).
After that you can just use jQuery.load
or any other ajax request.
Otherwise it isn't possible (cross domain policy) as mentioned a couple of times already.
来源:https://stackoverflow.com/questions/18978034/include-part-of-a-website-in-my-website