너무 막혀서 질문드립니다. 정보
너무 막혀서 질문드립니다.본문
<SCRIPT LANGUAGE='JavaScript'>
// 이미지뷰어
<!--
var win= null;
function View_Open(img, w, h)
{
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/3;
var settings ='height='+h+',';
settings +='width='+w+',';
settings +='top='+wint+',';
settings +='left='+winl+',';
settings +='scrollbars=yes,';
settings +='resizable=yes,';
settings +='status=no';
win=window.open("","newWindow",settings);
win.document.open();
win.document.write ("<html><head><title>Detail Zoom</title></head>");
win.document.write ("<script>function init(){window.resizeBy(document.all.pop_img.width-document.body.clientWidth, document.all.pop_img.height-document.body.clientHeight+10);}</script>");
win.document.write ("<body bgcolor=white topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 oncontextmenu='return false' ondragstart='return false' onkeydown='return false' onselectstart='return false' onload='init();'>");
win.document.write ("<img src='"+img+"' border=0 onclick='window.close();' style='cursor:hand' title='닫기' id='pop_img'>");
win.document.write ("</body></html>");
win.document.close();
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
clear = new Image();
<?
//파일 뽑기
$sql2 = " select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 10 ";
$result2 = sql_query($sql2);
for ($j=0; $row2 = sql_fetch_array($result2); $j++) {
if($j==0) {
$view_one = "{$g4['path']}/data/file/{$bo_table}/{$row2['bf_file']}";
}
?>
view_img<?=$j?> = new Image();
view_img<?=$j?>.src = "<?=$g4['path']?>/data/file/<?=$bo_table?>/<?=$row2['bf_file']?>";
<? } ?>
function bgChange(imgName) {
document.all.view_img.src = eval(imgName + ".src");
}
// -->
</SCRIPT>
<div>
<a href="javascript:void(0);" onClick="View_Open('<?=$view_one?>')"><img src="<?=$view_one?>" name="view_img" width=440 height=600></a>
</div>
<div>
<?
//파일 뽑기
$sql = " select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 10 ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
//썸네일 코드 시작
$data_path = $g4['path'] . "/data/file/{$bo_table}";//라이브러리 파일 참조
$thumb_path = $data_path . '/thumbOpen';
$view_w = 80; //썸네일 가로사이즈
$view_h = 109; //썸네일 세로사이즈
$sch_q = 99; //썸네일 퀼리티
if (!is_dir($thumb_path)) {
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}
$filename = $row[bf_file]; //파일명
$thumb = $thumb_path.'/'.$filename; //썸네일
if (!file_exists($thumb))
{
$file = $data_path.'/'.$filename; //원본
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file))
{
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
continue;
$rate = $view_w / $size[0];
$height = (int)($size[1] * $rate);
if ($height < $view_h)
$dst = imagecreatetruecolor($view_w, $height);
else
$dst = imagecreatetruecolor($view_w, $view_h);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $view_w, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$filename, $sch_q);
chmod($thumb_path.'/'.$filename, 0707);
}
}
if (file_exists($thumb) && $filename) {
?>
<a href="javascript:void(0);" onClick="bgChange('view_img<?=$i?>');"><img src='<?=$thumb?>' style='margin-right:5px;' border=0></a><?
}
}
?>
</div>
간단한 상품소개 게시판입니다.
스크립트가 오픈창과 사진체인지 두가지가 있습니다.
우선 view화면으로 들어가면
윗부분에 1번사진이 들어가고,
아랫부분에는 1번부터 순차적으로 작은사진들로 썸네일이 구성됩니다.
썸네일로 구성된 사진들을 클릭하면
윗부분의 사진이 클릭된 사진으로 체인지되는데.
큰사진을 클릭하게 되면 원본크기의 사진이 오픈창으로 열리게되있습니다.
문제는 아래의 썸네일사진을 누르면 큰사진으로 바뀌기는 하는데,
큰사진을 클릭해도 1번 사진만 오픈창으로 떠집니다.
썸네일을 클릭해서 바껴진 사진으로 오픈창으로 보고싶습니다. 도와주세요 ㅠ
// 이미지뷰어
<!--
var win= null;
function View_Open(img, w, h)
{
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/3;
var settings ='height='+h+',';
settings +='width='+w+',';
settings +='top='+wint+',';
settings +='left='+winl+',';
settings +='scrollbars=yes,';
settings +='resizable=yes,';
settings +='status=no';
win=window.open("","newWindow",settings);
win.document.open();
win.document.write ("<html><head><title>Detail Zoom</title></head>");
win.document.write ("<script>function init(){window.resizeBy(document.all.pop_img.width-document.body.clientWidth, document.all.pop_img.height-document.body.clientHeight+10);}</script>");
win.document.write ("<body bgcolor=white topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 oncontextmenu='return false' ondragstart='return false' onkeydown='return false' onselectstart='return false' onload='init();'>");
win.document.write ("<img src='"+img+"' border=0 onclick='window.close();' style='cursor:hand' title='닫기' id='pop_img'>");
win.document.write ("</body></html>");
win.document.close();
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
clear = new Image();
<?
//파일 뽑기
$sql2 = " select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 10 ";
$result2 = sql_query($sql2);
for ($j=0; $row2 = sql_fetch_array($result2); $j++) {
if($j==0) {
$view_one = "{$g4['path']}/data/file/{$bo_table}/{$row2['bf_file']}";
}
?>
view_img<?=$j?> = new Image();
view_img<?=$j?>.src = "<?=$g4['path']?>/data/file/<?=$bo_table?>/<?=$row2['bf_file']?>";
<? } ?>
function bgChange(imgName) {
document.all.view_img.src = eval(imgName + ".src");
}
// -->
</SCRIPT>
<div>
<a href="javascript:void(0);" onClick="View_Open('<?=$view_one?>')"><img src="<?=$view_one?>" name="view_img" width=440 height=600></a>
</div>
<div>
<?
//파일 뽑기
$sql = " select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 10 ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
//썸네일 코드 시작
$data_path = $g4['path'] . "/data/file/{$bo_table}";//라이브러리 파일 참조
$thumb_path = $data_path . '/thumbOpen';
$view_w = 80; //썸네일 가로사이즈
$view_h = 109; //썸네일 세로사이즈
$sch_q = 99; //썸네일 퀼리티
if (!is_dir($thumb_path)) {
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}
$filename = $row[bf_file]; //파일명
$thumb = $thumb_path.'/'.$filename; //썸네일
if (!file_exists($thumb))
{
$file = $data_path.'/'.$filename; //원본
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file))
{
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
continue;
$rate = $view_w / $size[0];
$height = (int)($size[1] * $rate);
if ($height < $view_h)
$dst = imagecreatetruecolor($view_w, $height);
else
$dst = imagecreatetruecolor($view_w, $view_h);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $view_w, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$filename, $sch_q);
chmod($thumb_path.'/'.$filename, 0707);
}
}
if (file_exists($thumb) && $filename) {
?>
<a href="javascript:void(0);" onClick="bgChange('view_img<?=$i?>');"><img src='<?=$thumb?>' style='margin-right:5px;' border=0></a><?
}
}
?>
</div>
간단한 상품소개 게시판입니다.
스크립트가 오픈창과 사진체인지 두가지가 있습니다.
우선 view화면으로 들어가면
윗부분에 1번사진이 들어가고,
아랫부분에는 1번부터 순차적으로 작은사진들로 썸네일이 구성됩니다.
썸네일로 구성된 사진들을 클릭하면
윗부분의 사진이 클릭된 사진으로 체인지되는데.
큰사진을 클릭하게 되면 원본크기의 사진이 오픈창으로 열리게되있습니다.
문제는 아래의 썸네일사진을 누르면 큰사진으로 바뀌기는 하는데,
큰사진을 클릭해도 1번 사진만 오픈창으로 떠집니다.
썸네일을 클릭해서 바껴진 사진으로 오픈창으로 보고싶습니다. 도와주세요 ㅠ
댓글 전체