一、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>都创建为层,这样可实现显示和隐藏功能。
1.另一个Frame中的JavaScript变量:
var 可在其他框架中使用:
Frame名.变量名 来调用
2.<Table>中
<TR> -- Table Row
<TD> -- Table Data
3.<IMG>元素
<IMG src="图片路径" alt="提示">
4.DOM 模型
+ forms[]
| images[]
+ frames [] -- document -| anchors[]
| document | ...
| navigator + applets[]
window --| history
| status 属性
+ location
5.事件
1> onClick ,onLoad 等不是 事件处理函数(event handler)而是 事件 (event);
2> 对照表
------------------+------------------------
Object | Event
------------------+------------------------
window,FrameSet | onLoad
Frame | onUnload
------------------+------------------------
Button,IMG,Frame | onClick
| onMouseDown
| onMouseUp
| onMouseMove
------------------+------------------------
3>事件处理函数
function startUp(){
document.onmousedown = maptool;//maptool是函数名
}
function maptool(){
...
}
<body onload = "startUp()">
4>
event.clientX
event.clientY 鼠标坐标,相对于包容窗口左上角
event.offsetX
event.offsetY 鼠标坐标,相对于源元素位置
5>onUnload事件含义:
Browser已经离开使用框架、document网页,在转入其它页之前的事件