我想在我的 html 页面中显示 html 电子邮件
这是我的简化版 index.html
<!DOCTYPE html>
<html class="no-js" lang="">
<head></head>
<body>
<div id='email_goes_here'></div>
</body>
</html>
这就是我的 email.html
的开始
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
....
我想输入 email.html
中的代码里面div#email_goes_here
来自index.html
.
仅将代码复制并粘贴到 div 中是否有效?我不确定 2 <!DOCTYPE html>
的 html 是否有效和 2 <html>
标签。如果它无效,我如何在另一个 html 页面中显示该 html 页面?任何使用 PHP 或 jQuery 的方法都可以。
我一直在寻找这个问题,但没有找到任何东西。我只找到了如何在另一个html文件中包含一些html内容的问题,但没有找到如何包含完整的html页面的问题。以下是我找到的链接:
Include another HTML file in a HTML file
view html page inside another html
How do I load an HTML page in a <div> using JavaScript?
How to include an HTML page into another HTML page without frame/iframe?
最佳答案
最简单的方法是使用 <iframe>
.
如果您使用srcdoc
属性,您将避免设置任何外部 html 文档。
工作示例:
<iframe srcdoc="
<html>
<head>
<style>p{color: rgb(255,0,0);}</style>
</head>
<body>
<p>This is an example of an <code>iframe</code> which uses the <code>srcdoc</code> attribute.</p>
</body>
</html>
">
</iframe>
进一步阅读: https://developer.mozilla.org/en/docs/Web/HTML/Element/iframe
关于php - 在 html 文件中包含 html 电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42386307/