繁体   English   中英

如何将网页嵌入到另一个网站

[英]How to embed a webpage in another website

我正在尝试从另一个网站嵌入日历,但我不太明白如何。 我尝试了嵌入和脚本标签,似乎没有任何效果。 另外,我不明白最后的 JSON 指令。

Go to https://www.crestinortodox.ro/embed/agendacrestinului/listacalendar/mycss/
and you can use this calendar on your webpage.
Use the 'callbackjs' parameter for JSON-P.

我知道这听起来像是一个新手问题,但我真的不知道如何处理 URL。 我不想将它嵌入为 iframe,我希望它包含在网页代码中,以便我可以使其响应,添加 CSS 等等。

这是一个添加代码并为其创建 CSS 的网站:ww.bisericaicoanei.ro - 在右侧,其中显示日历 Ortodox。

您可以使用跨域资源共享将页面内容放在 div 或任何标签中。
例如:

xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
  if(xhr.readyState == 4 && xhr.status == 200) {
    document.getElementById('displayDiv').innerHTML = xhr.responseText;
  }
};
xhr.open('GET', 'https://some.example.com', true);
xhr.send();

然后您需要在服务器端代码中设置Access-Control-Allow-Origin header,例如在 php 中:

<?php
  header('Access-Control-Allow-Origin: http://api.google.com');
  header('Access-Control-Allow-Origin: http://some.example.com');
?>

查看此答案以获取更多信息: https://stackoverflow.com/a/41498465/11365636
您可以使用<enbed>元素,例如:

<embed src="https://github.com/AbrarJahin/Asp.NetCore_3.1-PostGRE_Role Claim_Management/"
width=200
height=200
onerror="alert('URL invalid!');" />

或者
您可以使用<object>元素,例如:

<object data="https://github.com/AbrarJahin/Asp.NetCore_3.1-PostGRE_Role-Claim_Management/"
width="400"
height="300"
type="text/html">
    Alternative Content
</object>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM