1.官网下载js,并把js放到页面要显示的元素里面
2.在body上添加onload方法
3.js里面编写代码
代码如下:
function WebOpen(){
obj = document.getElementById('WebOffice');//获得控件对象
if (obj)setTimeout('openfile()',1000);//等待控件初始化完毕,时间可以根据网络速度设定。
}
function openfile()
{
//获取文件名
var pfile="hi.docx";
var strOpenUrl="";
$.ajax({
type : "post",
url : "../../br/detial/problem/getTomcatPath",
data :"",
dateType : "json",
success : function(result) {
strOpenUrl= result+"detialProblemImg/"+ pfile ; //取得打开路径和文件名
document.getElementById('WebOffice').Open(strOpenUrl,false,"Word.Document");
/* document.getElementById('WebOffice').LoadOriginalFile("http://localhost:8080/MTJC/detialProblemImg/hi.doc","doc"); */
}
});
}
特别提醒:运行插件需要安装插件环境,官网都有下载