生活随笔
收集整理的這篇文章主要介紹了
LoadWebOffice实现在线编辑Word
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
LoadWebOffice實現在線編輯Word
1.準備工作
- (1)LoadWebOffice.js 提取碼:iyk4
- (2)weboffice.ocx 提取碼:nde6
2.代碼塊
LoadWebOffice目前適用于IE瀏覽器,火狐和谷歌瀏覽器要想使用需要安裝Firefox ActiveX Plugin,下面的LoadWebOffice.js內容代碼火狐和谷歌部分因需求變動未進行測試。
var s
= "";
if(navigator
.userAgent
.indexOf("MSIE")>0){s
= "<OBJECT id='WebOffice1' align='middle' style='LEFT: 0px; WIDTH: 100%; TOP: 0px; HEIGHT:768px'"+ "classid=clsid:E77E049B-23FC-4DB8-B756-60529A35FAD5> codebase='Common/weboffice.ocx#Version=5,0,0,0'"+ "</OBJECT>";
}
if(navigator
.userAgent
.indexOf("Chrome")>0){s
= "<object id='WebOffice1' type='application/x-itst-activex' align='baseline' border='0'"+ "style='LEFT: 0px; WIDTH: 100%; TOP: 0px; HEIGHT: 768px'"+ "clsid='{E77E049B-23FC-4DB8-B756-60529A35FAD5}' codebase='Common/weboffice.ocx#Version=5,0,0,0'"+ "event_NotifyCtrlReady='WebOffice1_NotifyCtrlReady'>"+ "</object>";
}if(navigator
.userAgent
.indexOf("Firefox")>0){s
= "<object id='WebOffice1' type='application/x-itst-activex' align='baseline' border='0'"+ "style='LEFT: 0px; WIDTH: 100%; TOP: 0px; HEIGHT: 768px'" + "clsid='{E77E049B-23FC-4DB8-B756-60529A35FAD5}' codebase='Common/weboffice.ocx#Version=5,0,0,0'"+ "event_NotifyCtrlReady='WebOffice1_NotifyCtrlReady'>"+ "</object>";
}
document
.write(s
)
<script language
="javascript" event
="NOtifyCtrlReady" for="WebOffice1">WebOffice1_NotifyCtrlReady();</script
><script
>function WebOffice1_NotifyCtrlReady() {$
.ajax({async: false,type
: "post",data
: {action
: ""},url
: "",success
: function (data
) {path
= data
.FiledKey
;document
.all
.WebOffice1
.LoadOriginalFile(path
,"doc");},error
: function (XMLHttpRequest
, textStatus
, errorThrown
) {layer
.alert('請求發生異常!', { icon
: 3 });}});}function window_onunload() {document
.all
.WebOffice1
.Close();}function upload() {document
.all
.WebOffice1
.HttpInit(); document
.all
.WebOffice1
.HttpAddPostString("DocTitle", "test1");document
.all
.WebOffice1
.HttpAddPostString("DocID", "");document
.all
.WebOffice1
.HttpAddPostString("DocType", "doc");document
.all
.WebOffice1
.HttpAddPostCurrFile("DocContent", ""); var result
= document
.all
.WebOffice1
.HttpPost("");if ("succeed" == result
) {alert("文件上傳成功");} elsealert("文件上傳失敗")return_onclick();}</script
><body onunload
="return window_onunload()"><form id
="form1" runat
="server"><input type
="button" onclick
="return upload()" class="layui-btn layui-btn-xs" value
="上傳文檔"/><br
/><br
/><script src
="../jscss/js/LoadWebOffice.js"></script
></form
>
</body
>
總結
以上是生活随笔為你收集整理的LoadWebOffice实现在线编辑Word的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。