Search code examples
jqueryhtmltwitter-bootstrappopover

Anchor inside Bootstrap popover not working on IE 8


Goal

To have anchor links inside a Bootstrap popover work on IE 8

Problem

Internet Explorer 8 seems to do absolutely nothing when these links are clicked inside the popover.

Other browser I have tested (Latest Chrome, Latest Firefox) work fine.

Hovering over the link does change the Status toolbar...

Imagine showing IE 8 status bar reacting to a link

Third party plugins used

  • jQuery 1.11.1
  • Bootstrap 3.2.0 JS
  • Bootstrap 3.2.0 CSS

Code (don't want to use the new code snippet thing as it prevents links working correctly)

<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body>

    <p>Hello, <a href="#" class="pop" tabindex="0" data-title="<b>Search Engines</b>" data-content='&#149; <a href="http://google.co.uk" target="_NEW">Google</a><br>&#149; <a href="http://bing.co.uk" target="_NEW">Bing</a><br>&#149; <a href="http://yahoo.co.uk" target="_NEW">Yahoo</a>'>visit &amp; search here</a></p>

    <script>
        var options = {
            placement: "bottom",
            html: true,
            trigger: "focus",
            toggle: "popover"
        };

        $(".pop").popover(options).click(function(e) {
            e.preventDefault();
        });
    </script>

</body>
</html>

Solution

  • I changed the trigger from focus to click and the issue was resolved on IE 8 and continued to work on other tested browsers.

    Changing this caused the auto hide to stop working so I amended the js function...

    $(".poper").popover(options).click(function(e){
        e.preventDefault();
        $('.poper').not(this).popover('hide'); // here is the new bit
    });