2012-07-09 51 views
0

我正在使用document.write()將javascript代碼寫入JavaScript。使用document.write()將結果寫入單獨的頁面

但結果出現在同一頁面,我想在單獨的頁面中顯示結果。

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>'); 

因此,此表格正在網頁中顯示,我希望此結果顯示在另一個網頁上。

謝謝先進。

+0

,whay你在寫'document.write' – 2012-07-09 11:31:12

回答

1

試試這個

var doc =window.open('','mydoc', 
    'width=350,height=250' 
    +',menubar=0' 
    +',toolbar=1' 
    +',status=0' 
    +',scrollbars=1' 
    +',resizable=1'); 
doc.document.writeln(
    '<html><head><title>doc</title></head>' 
    +'<body >' 
    +'something' 
    +'</body></html>' 
); 
+0

感謝謝赫扎德。如果我想通過使用(window.location =「mailto)將我的帖子中的上述數據發送到Outlook,它帶有HTML標籤而不是表格格式。這裏有任何想法嗎? – alkhader 2012-07-09 11:49:37

+0

讓我看看代碼 – 2012-07-09 12:35:40

4

使用window.open()先寫這個窗口:如果你想在另一頁結果

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