Javascript打印功能-文件名 [英] Javascript Print function - file name
本文介绍了Javascript打印功能-文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用javaScript中的window.print()函数来打印通过按钮onClick执行的页面.
I am using the window.print() function in javaScript to print a page which is executed from a button onClick.
<input type="submit" value="Print" class="register-button" onClick="window.print()"/>
在弹出窗口中,默认文件名是在标题中找到标签的网站名称.
In the popup the default filename is the name of the website found it the tags in the header.
反正我可以在函数中设置一个参数,所以默认的保存文件名就是我想要的文件名吗?
Is there anyway I can set a parameter in the function so the default save filename is what ever I want it to be?
干杯.
推荐答案
onClick ="document.title ='我的新标题'; window.print();"
您可以在这里尝试
<html>
<head>
<title>My title</title>
</head>
<body>
<button onClick="document.title = 'My new title';window.print();">Try it</button>
<p id="demo"></p>
</body>
</html>
这篇关于Javascript打印功能-文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文