如何将非变量文本添加到javascript打印弹出窗口?

如何将非变量文本添加到javascript打印弹出窗口?,javascript,printing,popup,Javascript,Printing,Popup,我有一个菜谱博客,有一个选项可以打印博客文章中的菜谱,这一切都设置好了,效果很好,使用以下javascript打印正确的内容: <script type='text/javascript'> // Print recipe using iframe function printRecipe(){ var content = document.getElementById(&quot;recipe&quot;); var pri = document.getEleme

我有一个菜谱博客,有一个选项可以打印博客文章中的菜谱,这一切都设置好了,效果很好,使用以下javascript打印正确的内容:

<script type='text/javascript'>

// Print recipe using iframe
function printRecipe(){
var content = document.getElementById(&quot;recipe&quot;);
var pri = document.getElementById(&quot;ifmcontentstoprint&quot;).contentWindow;
pri.document.open();
pri.document.write(content.innerHTML);
pri.document.close();
pri.focus();
pri.print();
}

//使用iframe打印配方
函数printprecipe(){
var content=document.getElementById(“配方”);
var pri=document.getElementById(“ifmcontentstoprint”).contentWindow;
pri.document.open();
pri.document.write(content.innerHTML);
pri.document.close();
pri.focus();
pri.print();
}
我想做的是在每个“打印配方”的底部添加一个带有网址的页脚。这将是不变的配方之间的配方,但我不希望它显示在原来的配方,所以它需要显示只有当配方打印。所以我知道我必须在代码中的某个地方添加它,但到目前为止我没有运气

我试图搜索大量的论坛,但对于一个简单的问题却没有真正的答案

请帮忙! 谢谢。

在这一行之后:

pri.document.write(content.innerHTML);
添加页脚:

pri.document.write("My custom footer! Can include HTML");
最终代码:

<script type='text/javascript'>

// Print recipe using iframe
function printRecipe(){
var content = document.getElementById("recipe");
var pri = document.getElementById("ifmcontentstoprint").contentWindow;
pri.document.open();
pri.document.write(content.innerHTML);
pri.document.write("My custom footer! Can include HTML");
pri.document.close();
pri.focus();
pri.print();
}
</script>

//使用iframe打印配方
函数printprecipe(){
var content=document.getElementById(“配方”);
var pri=document.getElementById(“ifmcontentstoprint”).contentWindow;
pri.document.open();
pri.document.write(content.innerHTML);
pri.document.write(“我的自定义页脚!可以包含HTML”);
pri.document.close();
pri.focus();
pri.print();
}

+1。注意(对于OP)“可以包含HTML”也意味着可以应用适当的样式。非常感谢!我问了这么多人,直到现在还没有人给我答案!!它起作用了!:-)好吧,至少现在你知道去哪里寻求帮助了!:)+1取消-1,不知道为什么这个问题被否决。