简体   繁体   中英

Fancybox iframe openning only first link

I am a layman in html, but for my personal website, I am trying to add some lightbox (Fancybox).

The problem I am facing is that it is only opening the first link as the lightbox, not the 2nd one. If I interchange the position (ie the 2nd link which was not opening became 1st) then the present first link is opening, and not the previous one. I have tried to make an minimal example:

index.html:

<!DOCTYPE html>
<head>
<title>Learning Fancybox</title>
<script>
!window.jQuery && document.write('<script src="jquery-1.4.3.min.js"><\/script>');
</script>
<script type="text/javascript" src="./fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="./fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<script type="text/javascript">
$(document).ready(function() {
    $("#iframe").fancybox({
        'width'         : '75%',
        'height'        : '75%',
        'autoScale'     : false,
        'transitionIn'  : 'none',
        'transitionOut' : 'none',
        'type'          : 'iframe'
        });
});
</script>
</head>
<body>
<div id="content">
  <table cellpadding="10" cellspacing="0" border="0">
    <tr>
      <td>
        <h3>Trying Fancybox</h3>
          <li><a id="iframe" href="jbn.html" />content1</a></li>
          <li><a id="iframe" href="chabi.html" />content2</a></li>
      </td>
    </tr>
  </table>
</div>
</body>
</html>

content1(jbn.html)

<!DOCTYPE html>
<head>
<title>content2</title>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/>
</head>

<body>
<div id="container">
  <div id="header">
    <div id="content">
      Some txt for content2
    </div>
  </div>
</div>
</body>
</html>

and content 2(chabi.html)

<!DOCTYPE html>
<head>
<title>lb content1</title>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/>
</head>

<body>
<div id="container">
  <div id="header">
    <div id="content">
      Some txt here
    </div>
  </div>
</div>
</body>
</html>

As it is now, the jbn.html is opening as lightbox, chabi.html is opening as an independent webpage.

Please help

UPDATE It is possibly not a fancybox problem, as I have just checked, if I add an identical id as #iframe2 and change the id of the 2nd links id to that, it is working properly. Please help.

通过将id更改为类(.iframe)来解决问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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