复制图像并链接到另一个网站

时间:2019-04-16 19:55:23

标签: html

我有2个网站,我在两个网站上都有一个带有链接的图像,所以当这些图像和链接中的一个被更改而另一个网站上的另一个也更改时,无论如何,这可能吗?

1 个答案:

答案 0 :(得分:3)

Your best options would be:

a) Use ajax to pull in the content on both sites, for example with jQuery:

<div id="linked-image"></div>
<script>
$('#linked-image').load('https://www.yoursite.com/file-with-your-html.html');
</script>

b) Use an iframe on both sites, both of which use a common src attribute:

<iframe src="https://www.yoursite.com/file-with-your-html.html"></iframe>

c) Use an API call to retrieve the image src and link href from a common endpoint source, and then load to both sites dynamically