如何使用网页书签和查询字符串

时间:2017-10-09 09:28:59

标签: codeigniter

我想访问ID为#hotel-amenities的标签部分,但此链接无效

  

http://localhost/travel/deals/package?action=packagedetails&destination=singapore&package=FFTS9965#hotel-amenities

此链接正常运行

  

http://localhost/travel/hotel-detailed.html#hotel-amenities

请帮忙

1 个答案:

答案 0 :(得分:2)

<a id="bookmarkme">Add Bookmark</a>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
    //Function for add bookmark this page
    $(function() {
      $('#bookmarkme').click(function() {
        if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark
          window.sidebar.addPanel(document.title, window.location.href, '');
        } else if (window.external && ('AddFavorite' in window.external)) { // IE Favorite
          window.external.AddFavorite(location.href, document.title);
        } else if (window.opera && window.print) { // Opera Hotlist
          this.title = document.title;
          return true;
        } else { // webkit - safari/chrome
          alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.');
        }
      });
    });
</script>