我有一个 Sprite ,单击它时应该打开 htm 帮助文件或视频,具体取决于单击的位置。
我尝试过 asp.net 图像 map 和客户端 map ,有或没有 window.open 以及发送到 javascript 函数。什么都不起作用。
我真的不想使用服务器端,但我似乎无法让它工作。
<div class="divhelp">
<br />
<asp:ImageMap
ID="ImageMap1"
runat="server"
ImageUrl="~/images2020/SpriteVideoandHelp.png"
Width="70"
Height="32"
HotSpotMode="NotSet">
<asp:RectangleHotSpot Target="_self" Top="0" Bottom="32" Left="0" Right="34" AlternateText="Videos" NavigateUrl="openVideoHelp('1')" />
<asp:RectangleHotSpot Target="_blank" Top="0" Bottom="32" Left="35" Right="70" AlternateText="Help" NavigateUrl="javascript:window.open('../HelpFiles/Login.htm', 'Search', 'width=600,height=450,left=150,top=200,scrollbars=1,toolbar=no,menubar=yes,status=1')" />
</asp:ImageMap>
</div>
<a href="#"><img src="images2020/SpriteVideoandHelp.png" alt="Videos and Help Files" width="70" height="32" border="0" usemap="#mapname"/></a><br />
<map id="mapname">
<area shape="rect" onclick="javascript:window.open('../HelpFiles/Login.htm','Search','width=650,height=500,left=150,top=200,scrollbars=1,toolbar=no,menubar=yes,status=1')" alt="Videos" coords="0,32,0,34"/>
<area shape="rect" onclick="javascript:window.open('../HelpFiles/Login.htm','Search','width=650,height=500,left=150,top=200,scrollbars=1,toolbar=no,menubar=yes,status=1')" alt="Help" coords="0,32,35,70" />
</map>
function openVideoHelp(imgClicked) {
if (imgClicked == '1') {
helpfile = window.open('../HelpFiles/Login.htm', 'Search', 'width=600,height=450,left=150,top=200,scrollbars=1,toolbar=no,menubar=yes,status=1');
return false;
}
else {
helpfile = window.open('../HelpFiles/Login.htm', 'Search', 'width=600,height=450,left=150,top=200,scrollbars=1,toolbar=no,menubar=yes,status=1');
return false;
};
};
我尝试过上述的其他几种变体,但没有成功。
我做错了什么或者这是不可能的?
感谢您的帮助。
最佳答案
您可以删除服务器端图像映射。
客户端图像映射的所有问题在于您已经切换了图像的宽度和高度。应该是width="32" height="70"
.
此外,视频区域的坐标混淆了:它应该显示为 <area coords="0,0,32,34"...
.
希望有帮助。
关于javascript - 客户端或服务器端 (asp.net) imagemap 都不会弹出 html 表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10807630/