我如何让JavaScript制作(制作)新的页面? [英] How can I make JavaScript make (produce) new page?

查看:79
本文介绍了我如何让JavaScript制作(制作)新的页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在可以在同一页面调用JS函数的页面上创建一个按钮。该函数需要创建(打开)新窗口,其HTML代码是从JS函数本身给出的。我该怎么做?

I would like to make a button on a page that can call a JS function in the same page. The function will need to create (open) new window which its HTML code was given from the JS function itself. How can I do that?

这样做的目的是从特定页面生成一个打印友好的页面。

The purpose of this is to produce a print friendly page out of a specific page.

请注意:不可以使用AJAX。

Please notice: No AJAX can be used.

推荐答案

var opened = window.open("");
opened.document.write("<html><head><title>MyTitle</title></head><body>test</body></html>");

这篇关于我如何让JavaScript制作(制作)新的页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆