ArcIMS学习之 HTML Viewer定制笔记 续四(4.动态效果DHTML)

来源:互联网 发布:easyui ssh项目源码 编辑:程序博客网 时间:2024/04/30 10:06

一、CSS基础:
Html:
<DIV id="xxx"    style="background-color:blue;
    left:20px;top:20px;
    position:absolute;
    visibility:visible;
    z-index:0">
</DIV>
Javascript:
 document.getElementById("xxx").style.visibility="hidden";

参数说明:
 <DIV id="xxx" style=""></DIV> 
  将其包括的其他HTML元素或文本应用到指定的样式规则(CSS)中,也称“容器”。
 background-color 背景色,Javascript为:xxx.style.backgroundColor
 clip   剪切指定部分来显示;其语法为:
     .style.clip="rect(top,right,bottom,left)";
     注意此参数的顺序不寻常;
     例:style.clip='rect(20 400 500 30)';
 left、top  与容器的相对位置
 position  指定位置规则如何使用,多个元素设绝对位置(absolute)可实现重叠
 visibility  CSS图层是否可见,有二值:visible 和 hidden
 z-index  指定元素重叠顺序,0位最底层,大于0的整数为上层,默认都为0层

二、ArcIMS使用(aimsDHTML.js)

 1.创建CSS层:
 function createLayer(name, inleft, intop, width, height, visible, content) {
   var layer;
   if (isNav4) {
     document.writeln('<layer name="' + name + '" left=' + inleft + ' top=' + intop + ' width=' + width + ' height=' + height +  ' visibility=' + (visible ? '"show"' : '"hide"') +  '>');
     document.writeln(content);
     document.writeln('</layer>');
   } else {
     document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + inleft + 'px; top:' + intop + 'px; width:' + width + 'px; height:' + height + 'px;' + '; z-index:1; visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
     document.writeln(content);
     document.writeln('</div>');
   }
}
 只要将要放入层内的内容写好调用createLayer即可;

 2.显示、隐藏层
 2.1辅助函数:
 得到层:
 function getLayer(name) {
   if (isNav4)
     return(document.layers[name]);
   else if (isIE4) {
     layer = eval('document.all.' + name + '.style');
     return(layer);
   } else if (is5up) {
  var theObj = document.getElementById(name);
  return theObj.style
   }
   else
     return(null);
  }
 2.2显示、隐藏层
 function showLayer(name){
  getLayer(name).visibility="visible";
  }
 function hideLayer(name){
  getLayer(name).visibility="hidden";
  }
 
 先将MapFrame中所有图片<IMG>都创建为层,这样可实现显示和隐藏功能。

原创粉丝点击