最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

printing - Javascript Print function - file name - Stack Overflow

programmeradmin0浏览0评论

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?

Cheers.

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?

Cheers.

Share Improve this question asked Dec 17, 2010 at 4:02 Samuel MeddowsSamuel Meddows 36.7k13 gold badges41 silver badges37 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 25

onClick="document.title = 'My new title';window.print();"

You can try it here:

    <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>

According to MDC, window.print() has no parameters to control anything.

https://developer.mozilla.org/en/DOM/window.print

发布评论

评论列表(0)

  1. 暂无评论