//?MAP1名稱

創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務,包含不限于做網(wǎng)站、網(wǎng)站設(shè)計、海倫網(wǎng)絡推廣、小程序制作、海倫網(wǎng)絡營銷、海倫企業(yè)策劃、海倫品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)為所有大學生創(chuàng)業(yè)者提供海倫建站搭建服務,24小時服務熱線:18980820575,官方網(wǎng)址:chinadenli.net
var?mapName1?=?"Map1";
//?MAP1ID
var?mapId1?=?"MapId1";
//?指定DIV名稱
var?divnId?=?"mask";
//?圖片路徑
var?imgPath?=?"";
main?=?function(type)?{
var?obj;
switch(type)?{
case?"aa"?:
//?指定圖片及熱點對象取得
obj?=?imgMapList[0];
//?創(chuàng)建圖片及熱點
creatImpAndHot(obj);
break;
}
}
creatImpAndHot?=?function(hotObj)?{
//?創(chuàng)建熱點MAP對象
var?map?=?document.createElement_x("Map");
//?設(shè)置MAP名稱
map.name?=?mapName1;
//?設(shè)置MAPID
map.id?=?mapId1;
//?熱點列表取得
var?length?=?hotObj.map.length;
for?(var?i?=?0;?i??length;?i++)?{
var?tempMap?=?hotObj.map[i];
//?創(chuàng)建熱區(qū)對象
area?=?document.createElement_x("area");
//?設(shè)置熱區(qū)類型
area.shape?=?tempMap.shape;
//?設(shè)置熱區(qū)坐標
area.coords?=?tempMap.coords;
//?設(shè)置熱區(qū)對應鏈接
area.href?=?tempMap.href;
//?設(shè)置熱區(qū)對應事件
area.onclick?=?tempMap.onclick;
//?設(shè)置熱區(qū)id
area.id?=??tempMap.id;
//?向MAP中追加熱區(qū)對象
map.appendChild(area);
}
//?創(chuàng)建圖片對象
var?img?=?document.createElement_x("img");
//?圖片ID
img.id?=?hotObj.img.id;
//?設(shè)置圖片鏈接
img.src?=?hotObj.img.imgName;?
//?設(shè)置圖片對應熱區(qū)MAP
img.useMap="#"?+?mapName1;
//?設(shè)置圖片尺寸
img.width?=?hotObj.img.width;?
img.height?=?hotObj.img.height;?
//?邊框
img.border?=?"0";
//?設(shè)置圖片ID
img.id?=?hotObj.id;
//?清空指定DIV內(nèi)容
document.getElementByIdx_x(divnId).innerHTML?=?'';
//?向DIV區(qū)添加MAP對象
document.getElementByIdx_x(divnId).appendChild(map);
//?向DIV區(qū)添加圖片對象
document.getElementByIdx_x(divnId).appendChild(img);
}
testClick?=?function()?{
alert();
}
creatImgAndMap?=?function(){
var?tempArray?=?new?Array();
var?tempObj?=?new?Object();
//?圖片ID
tempObj.img?=?new?Object();
tempObj.img.id?=?"test1";
//?圖片名稱(只要圖片名稱,路徑由公共變量設(shè)置)
tempObj.img.imgName?=?"113.jpg";
//?設(shè)置圖片尺寸
tempObj.img.width?=?"640";
tempObj.img.height?=?"200";
var?tempMap;
tempObj.map?=?new?Array();
//?熱點1
tempMap?=?new?Object();
//?熱區(qū)ID
tempMap.id?=?"test1_hot1"
//?類型
tempMap.shape?=?"rect";
//?熱區(qū)坐標
tempMap.coords?=?"159,167,238,191";
//?鏈接
tempMap.href?=?"#";
//?單擊事件
tempMap.onclick?=?testClick;
//?添加到列表中
tempObj.map[0]?=?tempMap;
//?熱點2
tempMap?=?new?Object();
//?熱區(qū)ID
tempMap.id?=?"test1_hot2"
//?類型
tempMap.shape?=?"rect";
//?熱區(qū)坐標
tempMap.coords?=?"147,7,286,33";
//?鏈接
tempMap.href?=?"#";
//?單擊事件
tempMap.onclick?=?testClick;
//?添加到列表中
tempObj.map[1]?=?tempMap;
//?將圖片及相應熱區(qū)信息添加到列表中
tempArray[0]?=?tempObj;
return?tempArray;
};
//?熱點映射
var?imgMapList?=?creatImgAndMap();
!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?""
html?xmlns=""
head
meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/
title無標題文檔/title
script?type="text/javascript"?src="img.js"?/script
script?type="text/javascript"
function?abc(){
main("aa");
}
/script
/head
body
div?id="mask"
input?type="button"????value="set"?onClick="abc()"
/div
/body
/html
div class="box"img src="" //div
.box{width:200px;height:200px;border-radius:50%;overflow:hidden;}
試試這個結(jié)構(gòu)和對應的css,這個應該是可以解決的。
前進: history.forward();=history.go(1);
后退: history.back();=history.go(-1);
但是如果加在熱區(qū)中
span class="start-tag"map?name="Maps"?id="Maps"?span class="start-tag"area?shape="rect"?coords="2,2,79,52"?href="javascript:history.go(-1);"??target="_blank"?span class="start-tag"area?shape="rect"?coords="77,2,166,52"?href="#"?span class="starttag"area?shape="rect"?coords="166,4,242,51"?href="#"?target="_blank"?spanclass="starttag"area?shape="rect"?coords="248,5,318,53"?href="javascript:history.go(1);"target="_blank"?/span class="end-tag"map
如果有target="_blank"這個屬性,就會打開一個新的窗口,所以前進和后退沒有起作用,所以需要刪掉這個屬性。
拓展資料
Javascript是一種由Netscape的LiveScript發(fā)展而來的原型化繼承的面向?qū)ο蟮膭討B(tài)類型的區(qū)分大小寫的客戶端腳本語言,于是Netscape的瀏覽器Navigator加入了Javascript,提供了數(shù)據(jù)驗證的基本功能,主要目的是為了解決服務器端語言,比如Perl,遺留的速度問題,為客戶提供更流暢的瀏覽效果。當時服務端需要對數(shù)據(jù)進行驗證,由于網(wǎng)絡速度相當緩慢,只有28.8kbps,驗證步驟浪費的時間太多。
你可以在圖片2左下角上面加一個熱區(qū),在那個熱區(qū)里也加個onclick事件就可以了。
圖片2這么寫
img src="" border="0" usemap="#Map3" /
map name="Map3" id="Map"area shape="rect" target="_blank" coords="具體坐標自己寫" href="JavaScript:你的click方法" /
/map
文章名稱:javascript熱區(qū),html熱區(qū)
標題網(wǎng)址:http://chinadenli.net/article2/dsejcic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗、App設(shè)計、網(wǎng)站制作、網(wǎng)站導航、搜索引擎優(yōu)化、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)