导航:首页 > 编程语言 > js动态添加热点

js动态添加热点

发布时间:2024-09-10 12:18:30

Ⅰ 如何实现地图热点区域动态变色 js

使用背景图片做圆角框,使用DIV+Css做圆角框代码比较复杂。鼠标经过变色,对于链接用a:hover实现;对于其他的就要用javaScript了。#header#mainNa

Ⅱ js图片上怎么设置热区

//MAP1名称
varmapName1="Map1";
//MAP1ID
varmapId1="MapId1";
//指定DIV名称
vardivnId="mask";
//图片路径
varimgPath="";
main=function(type){
varobj;
switch(type){
case"aa":
//指定图片及热点对象取得
obj=imgMapList[0];
//创建图片及热点
creatImpAndHot(obj);
break;
}
}
creatImpAndHot=function(hotObj){
//创建热点MAP对象
varmap=document.createElement_x("Map");
//设置MAP名称
map.name=mapName1;
//设置MAPID
map.id=mapId1;
//热点列表取得
varlength=hotObj.map.length;
for(vari=0;i<length;i++){
vartempMap=hotObj.map[i];
//创建热区对象
area=document.createElement_x("area");
//设置热区类型
area.shape=tempMap.shape;
//设置热区坐标
area.coords=tempMap.coords;
//设置热区对应链接
area.href=tempMap.href;
//设置热区对应事件
area.onclick=tempMap.onclick;
//设置热区id
area.id=tempMap.id;
//向MAP中追加热区对象
map.appendChild(area);
}


//创建图片对象
varimg=document.createElement_x("img");
//图片ID
img.id=hotObj.img.id;
//设置图片链接
img.src=hotObj.img.imgName;
//设置图片对应热区MAP
img.useMap="#"+mapName1;
//设置图片尺寸
img.width=hotObj.img.width;
img.height=hotObj.img.height;
//边框
img.border="0";
//设置图片ID
img.id=hotObj.id;
//清空指定DIV内容
document.getElementByIdx_x(divnId).innerHTML='';
//向DIV区添加MAP对象
document.getElementByIdx_x(divnId).appendChild(map);
//向DIV区添加图片对象
document.getElementByIdx_x(divnId).appendChild(img);
}
testClick=function(){
alert();
}
creatImgAndMap=function(){
vartempArray=newArray();
vartempObj=newObject();
//图片ID
tempObj.img=newObject();
tempObj.img.id="test1";
//图片名称(只要图片名称,路径由公共变量设置)
tempObj.img.imgName="113.jpg";
//设置图片尺寸
tempObj.img.width="640";
tempObj.img.height="200";
vartempMap;
tempObj.map=newArray();
//热点1
tempMap=newObject();
//热区ID
tempMap.id="test1_hot1"
//类型
tempMap.shape="rect";
//热区坐标
tempMap.coords="159,167,238,191";
//链接
tempMap.href="#";
//单击事件
tempMap.onclick=testClick;
//添加到列表中
tempObj.map[0]=tempMap;
//热点2
tempMap=newObject();
//热区ID
tempMap.id="test1_hot2"
//类型
tempMap.shape="rect";
//热区坐标
tempMap.coords="147,7,286,33";
//链接
tempMap.href="#";
//单击事件
tempMap.onclick=testClick;
//添加到列表中
tempObj.map[1]=tempMap;
//将图片及相应热区信息添加到列表中
tempArray[0]=tempObj;
returntempArray;
};
//热点映射
varimgMapList=creatImgAndMap();

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>无标题文档</title>
<scripttype="text/javascript"src="img.js"></script>
<scripttype="text/javascript">
functionabc(){
main("aa");
}
</script>
</head>
<body>
<divid="mask">
<inputtype="button"value="set"onClick="abc()">
</div>
</body>
</html>

阅读全文

与js动态添加热点相关的资料

热点内容
u盘内存还占着文件没有了 浏览:551
python123在线编程手机怎么用 浏览:511
保存配置文件的方法有哪些 浏览:827
php实时定位代码 浏览:204
办身份证需要携带哪些文件 浏览:249
品胜标准数据线多少A 浏览:689
生成手机版pdf文件 浏览:447
软件是所有程序 浏览:183
飞猫网盘下载工具 浏览:749
郑州长得联利苹果 浏览:643
esxi虚拟机版本 浏览:82
微信电脑版文件怎么弄出来的 浏览:891
js日历插件视频 浏览:493
win10creators易升 浏览:324
淘宝横向分类导航代码 浏览:1
如何看自己视频后台数据 浏览:65
ppt配色工具 浏览:883
微信pro病毒 浏览:16
如何查看网站结构层数 浏览:335
文件上传时查找不到桌面图片 浏览:686

友情链接