Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unwanted border around the image map area

Tags:

html

css

image

maps

I am using an Image map with a circular area. The problem is I get an unwanted border around the area in IE7. This border doesn't appear in FF and Chrome and also in IE8/IE9.

I tried adding border="0" to the image, css properties for the anchors i.e

a{ 
border:none !important;
outline:none !important;
}

but didn't work.

I also tried adding the IE fix onfocus="blur();" in the tag. This solved the issue in IE but then FF got the border now. Searched a lot and came through this fix which said it will fix the issue for FF when IE fix is used.

#parent_div *:active, #parent_div *:focus { overflow-x:hidden; outline:none; }

But sadly even this didn't work. I am using FF 9.0.1.

Any help will be greatly appreciated. Thanks in advance.

like image 329
Abhidev Avatar asked Jan 27 '12 08:01

Abhidev


4 Answers

img{border:none;}

and this is the fix for ie versions

<!--[if lte IE 6]>
<script type="text/javascript">
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{

   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)

      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""

            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "

            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle

            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"

            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML

            i = i-1
         }
      }
   }    
}
window.attachEvent("onload", correctPNG);
</script>
<![endif]-->

try this hope it helps !!!

like image 195
Madhu Beela Avatar answered Nov 16 '22 09:11

Madhu Beela


This is the solution:

onclick="blur()" onfocus="navigator.appName == 'Microsoft Internet Explorer' ? blur() : null"
like image 30
sally oldfield Avatar answered Nov 16 '22 09:11

sally oldfield


You could use conditional comments (more info here) + jQuery.

HTML:

<!-- 
    "old-ie" targets IE7 or less
    "ie8" targets IE8
    "ie" targets IE8+
-->

<!--[if lt IE 8]> <html lang="en" class="old-ie"> <![endif]-->
<!--[if IE 8]> <html lang="en" class="ie ie8"> <![endif]-->
<!--[if gt IE 8]> <html lang="en" class="ie"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->

<head>
...
</head>

<body>
    <a href="#link">
        <img src="/img/image.jpg" />
    </a>
</body>

</html>

jQuery:

// we first check if current browser is IE7 or older, than apply our "hack"

if (jQuery('html').is('.old-ie') === true) {
    jQuery('a').focus(function() { jQuery(this).blur(); });
}
like image 2
bdurao Avatar answered Nov 16 '22 07:11

bdurao


Well found a way to solve this issue...which is probably not a good way to go for. By using js browser detection we can apply the IE fix as follows which will not cause problems to other browsers(FF in my case)

if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) {
    document.getElementsByTagName('area')[0].onfocus = function () {this.blur();};
   }

Well please, if anyone finds a better solution then do post here. Thanks.

like image 1
Abhidev Avatar answered Nov 16 '22 07:11

Abhidev