网页转换成Word
主函数方法
function OpenWord(){
Layer1.style.border=0;
word = new ActiveXObject('Word.Application');
word.Application.Visible = true;
var mydoc=word.Documents.Add('',0,1);
myRange =mydoc.Range(0,1);
var sel=Layer1.document.body.createTextRange();
sel.select();
Layer1.document.execCommand('Copy');
sel.moveEnd('character');
myRange.Paste();
location.reload();
//word.ActiveWindow.ActivePane.View.Type=9;
}
页面调用
<div id="Layer1" >
<input type=button name='button_export' title='导出到word' onclick="OpenWord()" value="导出到word"></div>
</div>