gpt4 book ai didi

javascript - 使用 document.write() 将结果写入单独的页面

转载 作者:行者123 更新时间:2023-11-28 13:50:12 25 4
gpt4 key购买 nike

我正在使用 document.write() 将 html 代码写入 javascript。

但是结果出现在同一个页面中,我想在单独的页面中显示结果。

document.write('<table width="1000" border="1">');
document.write('<tr width="1000">');
document.write('<td width="100" bgcolor="#D8D8D8">Country</td>');
document.write('<td width="100" bgcolor="#D8D8D8">MCC</td>');
document.write('<td width="100" bgcolor="#D8D8D8">MNC</td>');
document.write('<td width="100" bgcolor="#D8D8D8">Network</td>');
document.write('<td width="100" bgcolor="#D8D8D8">Old Price</td>');
document.write('<td width="100" bgcolor="#D8D8D8">Current Price</td>');
document.write('<td width="100" bgcolor="#D8D8D8">Effective</td>');
document.write('<td width="100" bgcolor="#D8D8D8">Status</td>');
document.write('</tr>');
document.write('</table>');

所以这个表格正在网页中显示,我希望这个结果显示在另一个网页中。

最佳答案

首先使用window.open(),然后写入此窗口:

var w = window.open('','','width=200,height=100');
w.document.write("your html");

关于javascript - 使用 document.write() 将结果写入单独的页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11394166/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com