我可以打开一个新的窗口并用一个字符串变量填充吗? [英] Can I open a new window and populate it with a string variable?

查看:78
本文介绍了我可以打开一个新的窗口并用一个字符串变量填充吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在和一些似乎很简单的东西进行一场战斗。我有一个[JavaScript]字符串,其中包含DOM元素,并且想要打开一个新窗口(window.open()?),并使用填充新窗口的字符串。即让浏览器拿着字符串,并将其转换为HTML。这可能吗?

解决方案

是的,可以...

 code> var wnd = window.open(about:blank,,_blank); 
wnd.document.write(html);

这应该是诀窍。


I am having a bit of a battle with something that seems simple. I have a [javascript] string that has DOM elements in it and would like to open a new window (window.open()?) and use the string the populate the new window. i.e. have the browser take the string and convert it into HTML on the fly. Is this possible?

解决方案

Yes it's possible...

var wnd = window.open("about:blank", "", "_blank");
wnd.document.write(html);

That should do the trick.

这篇关于我可以打开一个新的窗口并用一个字符串变量填充吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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