jquery
  • fancybox
  • 2012-08-22 2 views 0 likes 
    0

    내가 fancybox은 iframe로를 통과하고 PHP 파일에 링크를 통과하는 즉시 A HREF를 구축하기 위해 노력하고있어는 Fancybox Iframe에로 동적 href가 전달

    <script type="text/javascript"> 
        jQuery(document).ready(function($){ 
        $('a').each(function(){ 
        var Href = 'GetImg.php?img=' + $(this).attr("href"); 
        alert ("Href"); 
        $(".Images").click(function() { 
    
          $.fancybox.open({ 
          href : Href, 
          type : 'iframe', 
          padding : 5 
          }); 
        }); 
        }; 
    
    }) ; // ready 
    </script> 
    

    Href에는 "(즉, 경고 설정되는 Href ") 그리고 PHP 파일로 전달했지만 iframe에서 열리지 않습니다. 은 참고 이것은 GetImg.php

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
    <html> 
        <head> 
        <meta http-equiv="content-type" content="text/html; charset=windows-1250"> 
        <meta name="generator" content="PSPad editor, www.pspad.com"> 
        <title>Holly Gibbons</title> 
    <script type="text/javascript" src="fancyBox-2.0.6/lib/jquery-1.7.2.min.js"></script> 
    
        <script type="text/javascript" src="/js/ddpowerzoomer.js"></script>  
    <script type="text/javascript"> 
    jQuery(function($){ 
        $('#image3').addpowerzoom({ 
         defaultpower: 2, 
         powerrange: [2,5], 
         largeimage: null, 
         magnifiersize: [100,100] //<--no comma following last option! 
        }); 
        }); 
        </script> 
        </head> 
        <body> 
        <?php 
        $my_img = $_GET['img']; 
        ?> 
    <p> <img id="image3" src = <?php echo $my_img ?> /></p> 
    </body> 
    </html> 
    
    +0

    선택기'$ ('a> img')'에 대해 확실합니까? 'img' 태그는 거기에없는 것 같습니다 ('a' 태그 내에서). –

    +0

    아니요, 오타입니다 & 편집했습니다 – Holly

    +0

    그리고'alert ("Href");'는 그냥'Href' 문자열을 출력합니다. –

    답변

    3

    모든 a 태그와 루프를 선택할 필요가 없습니다 내가 하드 코드 내 링크

    <a class="Images" href="/images/myImg.jpg" title="A witty Title">Send to PHP</a> 
    

    href : 'GetImg.php?img=/images/myImg.jpg' it works 
    

    되어

    경우, 당신은 간단하게 할 수있는 like

    $(document).on('click', '.Images', function(e) { 
        e.preventDefault(); 
        var Href = 'GetImg.php?img=' + $(this).attr("href"); 
        alert(Href); 
        $.fancybox.open({ 
         href: Href, 
         type: 'iframe', 
         padding: 5 
        }); 
    });​ 
    
    +0

    고맙습니다. 이제는 콘텐츠 기반의 iframe 크기를 조정하는 방법을 연습해야합니다. – Holly

    관련 문제