Java教程

ntko在线预览页面

本文主要是介绍ntko在线预览页面,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

《说明:先保证文件能被访问到具体去官网看实例及文档》

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
pageContext.setAttribute("ctx", path);
String extension = (String)request.getAttribute("extension");
%>
<!DOCTYPE html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<title>打开文档模板</title>
<script type="text/javascript" >
var cmnPath = "<%=basePath%>";
var path = "${path}";
var extension = "${extension}";
$(document).ready(function(){
var fileType="";
if(extension == "doc" || extension == "docx"){
fileType = "Word.Document";
}else if(extension == "xls" || extension == "xlsx"){
fileType = "Excel.Sheet";
}else if(extension == "ppt"){
fileType = "PowerPoint.Show";
}else{
fileType = "unkownfiletype";
}
var url = cmnPath+encodeURI(path);
var readonly = false;
var netOfficeEdit = document.getElementById("TANGER_OCX");
netOfficeEdit.OpenFromURL(url,readonly,fileType);
netOfficeEdit.FileNew = false;
netOfficeEdit.FileOpen = false;
netOfficeEdit.FileSaveAs = true;
//netOfficeEdit.FileSave = false;//是否可编辑参数
netOfficeEdit.attachEvent("OnFileCommand",function(cmd,canceled){
});
});

</script>
</head>

<body style="overflow: hidden;">
<object id="TANGER_OCX" classid="clsid:xxxxxxxxxxxxx" codeBase="<%=basePath%>static/ocx/OfficeControl.cab#version=xxxxx" width="100%" Height="100%">
<param name="BorderStyle" value="0">
<param name="BorderColor" value="14402205">
<param name="TitlebarColor" value="53668">
<param name="TitlebarTextColor" value="0">
<param name="ToolBars" value="false">
<param name="Menubar" value="false">
<param name="Caption" value="欢迎使用!">
<param name="Titlebar" value="0">
<param name="MaxUploadSize" value="10000000">
<param name="CustomMenuCaption" value="辅助选项">
<param name="ProductCaption" value="xxxxxxxxxxx">
<param name="ProductKey" value="xxxxxxxxxxxx">
<SPAN STYLE="color:red">不能装载文档控件。请在检查浏览器的选项中检查浏览器的安全设置。<a href="<%=basePath%>static/ocx/OfficeControl.cab">安装组件</a></SPAN>
</object>
</body>
</html>

这篇关于ntko在线预览页面的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!