ZitatJetzt wird mir die komplette Seite 1 angezeigt. Ich hatte jetzt den Ansatz nur den Button hier zu sehen, also den Rest im iFrame auszublenden
Wenn Du den iFrame nicht sehen möchtest, ist es kein Problem, ihn mit CSS und display:none unsichtbar zu machen.
Ich habe mal schnell ein Demo gemacht. Seite 2 mit dem Button und dem iFrame:
HTML
<!doctype html>
<html lang="en">
<head>
<title>Test download</title>
<meta charset="utf-8">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="html-docx-js-master/dist/html-docx.js"></script>
<script src="js/download.js"></script>
</head>
<body>
<iframe id="iframe" src="save-as-docx-content.html"></iframe>
<button onclick="save();">Als DOCX peichern</button>
<script>
function save() {
var iFrame = document.getElementById("iframe");
var thehtml = $(iFrame.contentWindow.document).find("html");
thehtml.find("script").remove();
var doc = '<!doctype html><html>' + thehtml.html() + '</html>';
var converted = htmlDocx.asBlob(doc, { orientation: 'portrait' });
download(converted, "specification.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
}
</script>
</body>
</html>
Alles anzeigen
Und save-as-docx-content.html ist die Seite mit der Tabelle, die gespeichert werden soll und dem Skript, das sie erzeugt.
Aber möglicher Weise verstehe ich dich noch falsch.