使用拓展控件加载,显示目录树。
注意事项
采用拓展控件的方式加载fly,是无法像原来的方法一样添加目录树控件在同一个页面的,只能通过popup弹出框的方式,在另一个页面中显示目录树,但不影响使用。
需求分析
- 控件加载
- 弹出自定义网页
- 目录树加载
方法说明
- 这里的方法以前的文章都用过了,不懂的就翻回去看看或者直接查API,现在点几个重点,这种加载方式通过技术人员指点才知道可以这样用,且只能通过popup方法弹出才能加载成功。
- 在子网页加载目录树需要注意的一点是,需要通过window.document.getElementById("TerraExplorerInformationWindow").focus();来显示目录树,如果不加这个方法,目录树需要鼠标点击一下才能显示,且该对象不接受click等事件,崩溃。。。
- 关于确定主体显示对象位置,可通过$("#TerraExplorer").offset().top;和$("#TerraExplorer").offset().left;获取屏幕上的坐标,然后反算pop的位置信息可作无缝显示,且通过ShowCaption属性可以引出pop的标题栏,显示效果就一模一样了。
Jsp源码
主网页
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=10">
<script src="${ctxStatic}/jquery/jquery-1.8.3.js" type="text/javascript"></script>
<script type = "text/javascript" >
var SGWorld66;
function init()
{
setTimeout(function () {
SGWorld66 = TerraExplorer.CreateInstance("TerraExplorerX.SGWorld66");
SGWorld66.Open("http://192.168.1.222:9090/20170330test/all.fly");
SGWorld66.Navigate.FlyTo(SGWorld66.Creator.CreatePosition(110.98775408994,19.64469583470,0,0,0,-30,0,700));
setTimeout("popup1();",2000);
//var X = $("#TerraExplorer").offset().top;
//var Y = $("#TerraExplorer").offset().left;
//alert(X + " " + Y);
}, 500);
}
//目录树
var popup1=function(){
//alert(document.body.scrollWidth + " " + document.body.scrollHeight);
var width = 500;
var height = 300;
var left = document.body.scrollWidth - width;
var top = document.body.scrollHeight - height;
var url = window.location.href;
var requiredUrl = url.substring(0, url.lastIndexOf("/")) + "/20170619mulushu.jsp";
var treePopup = SGWorld66.Creator.CreatePopupMessage("tree", requiredUrl, left, top, width, height);
treePopup.ShowCaption = false;
SGWorld66.Window.ShowPopup(treePopup);
};
</script>
</head>
<body onload="init()">
<!--定义插件对象-->
<object id="TerraExplorer" classid="CLSID:3a4f9196-65a8-11d5-85c1-0001023952c1" width="100%" height="1000px" style="float: left;"></object>
</body>
</html>
目录树网页
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<script type="text/javascript">
function init() {
window.document.getElementById("TerraExplorerInformationWindow").focus();
}
</script>
</head>
<body onload="init()" style="top:0;bottom:0;left:0;right:0;margin:0">
<div style="position:absolute;top:0;bottom:0;left:0;right:0;margin:0">
<object id="TerraExplorerInformationWindow" classid="CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1" style="width: 100%; height: 100%;" ></object>
</div>
</body>
</html>
效果图