테스트 사이트 - 개발 중인 베타 버전입니다

방법이 없을까요? 제가 너무 프로그래밍에 초짜라 채택완료

soyoung 4년 전 조회 2,421

 

</strong></p>

<p><script>

$(document).ready(function(){</p>

<p>jQuery.fn.center = function () {

    this.css("position","absolute");

    this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) - (88*2) + $(window).scrollTop()) + "px");

    return this;

}</p>

<p>

//사진닫기

    $("#showcase").click(function(){

        $(this).css("display", "none");

    });</p>

<p>

 }); </p>

<p>//사진보기 

function showImg(e){

    var e;

    $(".bimgs").remove();

    alert(e);</p>

<p>    $("div#showcase").append(e);

    $("#showcase").center();

    $("#showcase").css("display", "block");</p>

<p>    //var ff = $(".bimgs").attr("src");

}

//end</p>

<p>

</script></p>

<p> </p>

<p>    <?php</p>

<p>for ($i=0; $i<count($list); $i++) {

  $file = get_file($bo_table, $list[$i]['wr_id']);

  $thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $thumb_width, $thumb_height, false, true);</p>

<p>  for($j=0; $j<$file['count']; $j++) {

     $img_src[$j] = "<img src='".$file[$j]['path']."/".$file[$j]['file']."'>";

  }</p>

<p>  

  //    for ($i=0; $i<$list_count; $i++) {</p>

<p> //   $thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $thumb_width, $thumb_height, false, true);</p>

<p>    if($thumb['src']) {

       $img = $thumb['src'];

 //       $image = $thumb['ori'];</p>

<p>    } else {

        $img = G5_IMG_URL.'/no_img.png';

        $thumb['alt'] = '이미지가 없습니다.';

    }

    $img_content = '<img src="'.$img.'" alt="'.$thumb['alt'].'" >';

//    $wr_href = get_pretty_url($bo_table, $list[$i]['wr_id']);

    ?></p>

<p>





                    <td class="images">

                        <dl>

                            <dt>Images</dt>

                            <dd><a href="javascript:;" onclick="showImg(<?php echo $img_src[0]; ?>)" class="clip" alt=""><?php echo $img_content; ?></a></dd>

                        </dl>

                    </td></p>

<p><strong>

 

 

 

위에처럼 코딩하면 다음처럼 showImg () 안에 이미지 주소를 가져오는데요. 스크립트가 안먹혀요. 얼럿을 왜 안띄우는건지 이미지 경로만 가져와지면 좋겠는데 <img> 안붙이니까 에러나서 어떻게 이미지 주소만 가져올지 모르겠어요. view.skin.php에서 파일 부르는 코드를 넣어봤는데두 에러만 납니다.

 

 

</strong></p>

<p><dd></p>

<p><a href="javascript:;" onclick="showImg(<img src='<a href="http://dreamuse.net/data/file/gallery/1982826859_4ir2UXlG_476ebdf309ea89a714284bfc84c01ab6bfcdc118.png'>)"" target="_blank" rel="noopener noreferrer">http://dreamuse.net/data/file/gallery/1982826859_4ir2UXlG_476ebdf309ea89a714284bfc84c01ab6bfcdc118.png'>)"</a> class="clip" alt=""><img src="<a href="http://dreamuse.net/data/file/gallery/thumb-1982826859_4ir2UXlG_476ebdf309ea89a714284bfc84c01ab6bfcdc118_360x260.png"" target="_blank" rel="noopener noreferrer">http://dreamuse.net/data/file/gallery/thumb-1982826859_4ir2UXlG_476ebdf309ea89a714284bfc84c01ab6bfcdc118_360x260.png"</a> alt="" title=""></a></p>

<p></dd></p>

<p><strong>

댓글을 작성하려면 로그인이 필요합니다.

답변 3개

채택된 답변
+20 포인트

alert이 안 뜨는 이유는 함수안에 들어가는 파라미터 값이 잘못 들어갔기 때문 입니다.

저렇게 감싸는게 맞는지 헷갈리는데;;저쪽이 문제이니 한번 살펴보세요.

 

onclick="showImg('<img src="http://dreamuse.net/data/file/gallery/1982826859_4ir2UXlG_476ebdf309ea89a714284bfc84c01ab6bfcdc118.png">')"

 

그리고 경로만 가져오시려면

 

  for($j=0; $j<$file['count']; $j++) {
     $img_src[$j] = "<img src='".$file[$j]['path']."/".$file[$j]['file']."'>";
  }

 

위의 코드 중 $file[$j]['path']."/".$file[$j]['file'] 값을 활용하시면 됩니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

s
soyoung
4년 전
감사합니다.

댓글을 작성하려면 로그인이 필요합니다.

짱구79
4년 전

우선 for 루프가 닫히지 않았네요

 

49라인정도

 

}

?>

 

for 루프 닫는 중괄호(}) 가 빠졌습니다.

 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

<a href="javascript:;" onclick="showImg( '<?php echo htmlspecialchars( $img_src[0]); ?>')" class="clip" alt=""><?php echo $img_content; ?></a>

이렇게 하세요.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

s
soyoung
4년 전
감사합니다.

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인