简体   繁体   English

禁用javascript时隐藏图像地图坐标

[英]Hide image map coordinates when javascript is disabled

I have an image map and I want to hide its clickable coordinates when Javascript is disabled, so that only the image is left. 我有一个图像映射,我想在禁用Javascript时隐藏其可点击的坐标,以便只留下图像。 I tried using noscript in the html body: 我尝试在html体中使用noscript:

<noscript>
  <style type='text/css'>
    area {display:none}
  </style>
</noscript>

but the area coordinates still show underneath the image. 但区域坐标仍显示在图像下方。 How can I completely hide them (preferably using pure css or pure javascript)? 我怎样才能完全隐藏它们(最好使用纯CSS或纯JavaScript)?

Instead of having an image map be disabled if JavaScript isn't available, why not enable it only if JavaScript is available? 如果JavaScript不可用,而不是禁用图像映射,为什么不在JavaScript可用时才启用它? Since you only want the map to appear is JS is enabled, JS can be used to enable it. 由于您只想显示地图,因此启用了JS,可以使用JS来启用它。 Browsers with JS disabled will be unable to run the code and will only display the image. 禁用JS的浏览器将无法运行代码,只显示图像。

var myMappedImages = document.getElementsByClassName("myMappedImage");
for(var i=0,len=myMappedImages.length;i<len;i++){
    myMappedImages[i].usemap = "#myimagemap";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM