Jump to content

Fancybox Links not working


KillGorack

Recommended Posts

Working with some older php code, and Fancybox 2.1.5

We moved to getting js/css from CDNJS using:

<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.js" integrity="bla bla bla" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.css" integrity="bla bla bla" crossorigin="anonymous" />

Now the links within the fancy box, seems to be reloading the box again instead of following the link. I pretty sure it's a version issue, just cant get it to work..

<?php

   if(isset($pop)){
    if($pop['shw'] == true){
   //========================================================
   // A message with a forward button ot two
   //========================================================
     if($pop['typ'] == "MsgFwd"){
      echo "<script type=\"text/javascript\">";
        echo "$(document).ready(function() {";
          echo "$(\"#show_pop_message\").fancybox().trigger('click');";
        echo "});";
      echo "</script>";
      echo "<div id=\"show_pop_message\" style=\"display:none;\">";
      echo "<div class=\"cont_login\">";
      echo "<table cellpadding=\"2\" width=\"100%\" border=\"0\" cellspacing=\"0\">";
      echo "<tr>";
      echo "<td colspan=\"2\"><div class=\"text5\">".$pop['ttl']."</div></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td colspan=\"2\"><hr class=\"allform_div\"></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td style=\"vertical-align: text-top;\"><img src=\"".$pop['ico']."\" style=\"margin-right:10px;\"></td>";
      echo "<td><div class=\"text7\">".$pop['msg']."</div></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td colspan=\"2\"><hr class=\"allform_div\"></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td><div class=\"text6\" style=\"text-align:left;\">".$pop['nte']."</div></td>";
      echo "<td align=\"right\">";
      echo "<a href=\"".$pop['fwda']."\" id=\"NULL\"><img src=\"".$pop['btna']."\" style=\"margin-bottom:-5px; text-align:right;\"></a>";
      echo "</td>";
      echo "</tr>";
      echo "</table>";
      echo "</div>";
      echo "</div>";
   //========================================================
   // Just a message (Ok and it goes away)
   //========================================================
     }elseif($pop['typ'] == "MsgOk"){
      echo "<script type=\"text/javascript\">";
      echo "window.jQuery(document).ready(function() {";
      echo "$.fancybox.open('#unlnkForm');";
      echo "});";
      echo "$(':button').click(function() {";
      echo "parent.$.fancybox.close();";
      echo "})";
      echo "</script>";
      echo "<div id=\"unlnkForm\" style=\"display:none;\">";
      echo "<div class=\"cont_login\">";
      echo "<table cellpadding=\"2\" width=\"100%\" border=\"0\" cellspacing=\"0\">";
      echo "<tr>";
      echo "<td colspan=\"2\"><div class=\"text5\">".$pop['ttl']."</div></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td colspan=\"2\"><hr class=\"allform_div\"></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td><img src=\"".$pop['ico']."\" style=\"margin-right:10px;\"></td>";
      echo "<td><div class=\"text7\">".$pop['msg']."</div></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td colspan=\"2\"><hr class=\"allform_div\"></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td><div class=\"text6\" style=\"text-align:left;\">".$pop['nte']."</div></td>";
      echo "<td align=\"right\">";
      echo "<a href=\"javascript:parent.$.fancybox.close();\"><img src=\"".$pop['btna']."\" style=\"margin-bottom:-5px; text-align:right;\"></a>";
      echo "</td>";
      echo "</tr>";
      echo "</table>";
      echo "</div>";
      echo "</div>";
     }
   //========================================================
    }
   }

?>

using that mess up there with:

      $pop = array(
       "shw" => true,
       "typ" => "MsgFwd",
       "ttl" => "Success!",
       "msg" => "Thanks your changes have been made, please press the OK button below.",
       "ico" => "sty/img/ico/alert.png",
       "nte" => "",
       "fwda" => $lnk,
       "btna" => "sty/img/btn/ok.png"
      );

Any ideas on how to get the links within the box to work?

Edited by KillGorack
Link to comment
Share on other sites

I have a working solution, this seems to work..

From

<script type="text/javascript">
 $(document).ready(function() {
  $("#show_pop_message").fancybox().trigger('click');
 });
</script>

To

<script type=\"text/javascript\">
 window.jQuery(document).ready(function() {
  $.fancybox.open('#show_pop_message');
 });
</script>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.