如何在我的网页中嵌入具有特定名称属性的网页的一部分?

How do I embed a part of a webpage with a certain name attribute within my webpage?

有一个网页。我们称它为 Example.html。我不能 control/change 这个网页,但我想在我的网页中嵌入它的特定部分。

Example.html 网页有一个 HTML 代码,看起来像这样:

<!--[stuff I don't want]-->
<form action="/example/index.pl" method="post" enctype="multipart/form-data" name="windyNights">

<!--[stuff I want!]-->

<\form>

<!--[stuff I don't want]-->

那么如何在我的网页中包含我想要的内容而不包含我不需要的内容呢?有没有办法使用 name 属性以某种方式隔离它?

你可以试试

$('#target-div').load('http://www.example.com/Example.html form[name="windyNights"]');

您可以使用 iframe 和要显示的特定 div 的特定 ID,并根据您的目标 div 设置 iframe 的高度和宽度。 看例子:

#project_summary {
 width: 600px;
 height: 220px;
 padding: 15px 10px;
    background:black;
}
<iframe id="project_summary" src="https://towkir.github.io/projectindex/projects.html#rsp" scrolling="no" frameborder="0"></iframe>

分别访问iframe中的link,了解是怎么回事。