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

상품설명의 이미지 새창(팝업)으로 띄우기

· 14년 전 · 398 · 3
shop/popupimage.php 파일을 아래의 코드로 만듭니다.
 <?
include_once("./_common.php");
$g4[title] = "팝업이미지";
include_once("$g4[path]/head.sub.php");
$size = getimagesize($img);
$type =  $size[2];
if (!($type == 1 || $type == 2 || $type == 3)) {
    echo "<script> alert('이미지 파일이 아닙니다.'); window.close(); </script>";
    exit;
}
echo "<img id='popupimage' src='$img' $size[3] />";
$width  = $size[0] + 15;
$height = $size[1] + 32;
?>
<script>
$(function() {
    window.resizeTo(<?=$width?>,<?=$height?>);
    window.moveTo(parseInt(screen.width/2)-parseInt(<?=$width?>/2), (screen.height/2)-parseInt(<?=$height?>/2));
    $('#popupimage').click(function() {
        window.close();
    }).css('cursor', 'pointer').attr('title', '클릭하시면 창이 닫힙니다.');
});
</script>
<?
include_once("$g4[path]/tail.sub.php");
?>
 
 
shop/item.php 에 코드를 추가합니다.
<script>
$(function() {
    $('#div_explan img').each(function() {
        $(this).click(function() {
            window.open('./popupimage.php?img='+this.src, 'popupimage', 'status=0,scrollbars=0,resizable=1');
        })
        .css('cursor', 'pointer')
        .attr('title', '클릭하시면 원본이미지를 볼 수 있습니다.');
    });
});
</script> 

댓글 작성

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

로그인하기

댓글 3개

14년 전
감사합니다.^^
php 설정의 allow_url_fopen 을 On 으로 설정해야 정상 작동되는 것 같네요^^
13년 전
둥굴레

게시글 목록

번호 제목
1440
1434
1433
1428
1421
1397
1396
1388
1379
1378
1377
1367
1365
1362
1348
1343
1335
1318
1311
1310