将地图(坐标)指定给模态

时间:2015-05-10 21:31:35

标签: javascript html twitter-bootstrap

我正在寻找一种方法将地图(可点击区域)分配给模态,以便它像按钮一样工作。我附上我的代码。正如你所看到的,我有一张带有地图的图片,我想进一步链接到模态...还有一个链接到模态的按钮,它可以正常工作。我希望你明白我的意思。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>


</head>

<body>

<a href="http://s621.photobucket.com/user/viktorvnh/media/deskone_zpswpfj5mrc.jpg.html" target="_blank"><img src="http://i621.photobucket.com/albums/tt296/viktorvnh/deskone_zpswpfj5mrc.jpg" alt=" photo deskone_zpswpfj5mrc.jpg" usemap="#Map" border="0"/>
<map name="Map" id="Map">
  <area shape="rect" coords="374,414,624,570" href="#" />
</map>
</a>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Det här är innehållet</h4>
      </div>
      <div class="modal-body">
        DET HÄR ÄR OCKSÅ INNEHÅLLET<a href="http://s621.photobucket.com/user/viktorvnh/media/deskone_zpswpfj5mrc.jpg.html" target="_blank"><img src="http://i621.photobucket.com/albums/tt296/viktorvnh/deskone_zpswpfj5mrc.jpg" alt=" photo deskone_zpswpfj5mrc.jpg" width="540" height="358" border="0"/>
</a>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

</body>

</html>

1 个答案:

答案 0 :(得分:0)

你只需要在你的区域初始化模态并从包裹地图中删除href

<a>
    <img src="http://i621.photobucket.com/albums/tt296/viktorvnh/deskone_zpswpfj5mrc.jpg" usemap="#Map"/>
    <map name="Map" id="Map">
         <area shape="rect" coords="374,414,624,570" href="#" data-toggle="modal" data-target="#myModal"/>
    </map>
</a>