최신글 (자바스크립트) 한 페이지에 두개 출력 소스 문의드립니다. 정보
최신글 (자바스크립트) 한 페이지에 두개 출력 소스 문의드립니다.본문
제목 그대로 자바스크립트가 포함된 슬라이드 최신글을 한페이지에 두개 사용하고 싶은데..
현재 상태로는 두 번 써주면 슬라이드 동작이 제대로 안되네요..
질문게시판 검색 해 보면 자바 함수를 다르게 호출해 주면 된다는데.. 제가 초보라서 염치불구하고 도움 청합니다. 부탁드립니다.. 감사합니다..
<script type="text/javascript">
<!--
old_debate_F='1';
function ComeonF(objid_F){
document.getElementById("debate_F"+old_debate_F).style.display="none";
document.getElementById("debate_F"+old_debate_F+"#1").style.display="";
document.getElementById("debate_F"+objid_F+"#1").style.display="none";
document.getElementById("debate_F"+objid_F).style.display="";
document.getElementById("debate_content_F"+old_debate_F).style.display="none";
document.getElementById("debate_content_F"+objid_F).style.display="";
old_debate_F=objid_F;
}
var objid_F = 1;
var interval_best;
function best_changeF()
{
if( objid_F == 5 ) // 오버랩되는 갯수
objid_F = 1;
else
objid_F++;
ComeonF(objid_F);
}
function setInterval_best()
{
interval_best = setInterval("best_changeF()",4000);//속도조절
}
function clearInterval_best()
{
clearInterval(interval_best);
}
setInterval_best();
//-->
</script>
<table width="824" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<? for ($i=0; $i<count($list); $i++) {
$j = $i + 1;
if ($j == "1") {
echo "<div>";
echo "<div id=debate_content_F$j onmouseover=clearInterval_best() onmouseout=setInterval_best()>"; }
else { echo "<div id=debate_content_F$j onmouseover=clearInterval_best() onmouseout=setInterval_best() style='display:none;'>\n"; }
?>
<table width="100%" cellspacing="0" cellpadding="0" align="center">
<tr>
<?
//썸네일 생성
$thumfile = "";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
// 썸네일 이미지가 존재하지 않는다면...
if (!file_exists($thumb)) {
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
// 업로드된 파일이 이미지라면...
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
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면...
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
} else { //게디터에서 삽입한 이미지 생성
$edit_img = $list[$i]['wr_content'];
if (eregi("data/cheditor4/{$ym}/[^<>]*\.(gif|jpg|png|bmp)", $edit_img, $tmp)) { // data/geditor------
$file = './' . $tmp[0]; // 파일명
$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
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면...
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
}
if (file_exists($thumb))
$thumfile = "<td width='{$img_width}' valign='top'><a href='{$list[$i][href]}'><img src='{$thumb}' width='{$img_width}' height='{$img_height}' border='0' style='border:1px #ccc solid' alt=''></a><td width='10'></td>";
else
//이미지가 없으면...
$thumfile="<td width='5'></td><td>";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file))
{ $thumfile = "<script>doc_write(flash_movie('$file', 'flash$i', '$img_width', '$img_height', 'transparent'));</script>"; }
?>
<?=$thumfile?>
</td>
<td height="<?=$img_height+5?>" valign="top" style="color:#777;"><? if (!file_exists($thumb)) { ?><?=cut_str(strip_tags($list[$i][wr_content]),950,"...")?><? } else { ?><?=cut_str(strip_tags($list[$i][wr_content]),700,"...")?><? } ?></td>
<td width="5"></td>
</tr>
</table>
<?
echo "<img src='{$latest_skin_path}/img/icon_li.gif' width='16' height='9' alt=''> <B><a href='{$list[$i][href]}' style='color:#333; text-decoration:none;'>{$list[$i][subject]}</a></B>";
echo "</div>";
}
?>
<div class="r_latest_line"></div>
<div id="r_number_wrap">
<? for ($i=0; $i<count($list); $i++) {
$k = $i + 1;
?>
<a href="<?=$list[$i][href]?>" onmouseover="javascript:ComeonF('<?=$k?>')"><img src="<?=$latest_skin_path?>/img/<?=$k?>_on.gif" width="17" height="13" border="0" alt="" id="debate_F<?=$k?>" onmouseover="clearInterval_best()" onmouseout="setInterval_best()" <? if($k == "1") { echo ""; } else { echo "style='display:none;' "; } ?>><img src="<?=$latest_skin_path?>/img/<?=$k?>.gif" width="17" height="13" border="0" alt="" id="debate_F<?=$k?>#1" <? if($k == "1") { echo "style='display:none;'"; } else { echo ""; } ?>></a>
<? } ?>
</div>
</td>
</tr>
</table>
현재 상태로는 두 번 써주면 슬라이드 동작이 제대로 안되네요..
질문게시판 검색 해 보면 자바 함수를 다르게 호출해 주면 된다는데.. 제가 초보라서 염치불구하고 도움 청합니다. 부탁드립니다.. 감사합니다..
<script type="text/javascript">
<!--
old_debate_F='1';
function ComeonF(objid_F){
document.getElementById("debate_F"+old_debate_F).style.display="none";
document.getElementById("debate_F"+old_debate_F+"#1").style.display="";
document.getElementById("debate_F"+objid_F+"#1").style.display="none";
document.getElementById("debate_F"+objid_F).style.display="";
document.getElementById("debate_content_F"+old_debate_F).style.display="none";
document.getElementById("debate_content_F"+objid_F).style.display="";
old_debate_F=objid_F;
}
var objid_F = 1;
var interval_best;
function best_changeF()
{
if( objid_F == 5 ) // 오버랩되는 갯수
objid_F = 1;
else
objid_F++;
ComeonF(objid_F);
}
function setInterval_best()
{
interval_best = setInterval("best_changeF()",4000);//속도조절
}
function clearInterval_best()
{
clearInterval(interval_best);
}
setInterval_best();
//-->
</script>
<table width="824" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<? for ($i=0; $i<count($list); $i++) {
$j = $i + 1;
if ($j == "1") {
echo "<div>";
echo "<div id=debate_content_F$j onmouseover=clearInterval_best() onmouseout=setInterval_best()>"; }
else { echo "<div id=debate_content_F$j onmouseover=clearInterval_best() onmouseout=setInterval_best() style='display:none;'>\n"; }
?>
<table width="100%" cellspacing="0" cellpadding="0" align="center">
<tr>
<?
//썸네일 생성
$thumfile = "";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
// 썸네일 이미지가 존재하지 않는다면...
if (!file_exists($thumb)) {
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
// 업로드된 파일이 이미지라면...
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
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면...
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
} else { //게디터에서 삽입한 이미지 생성
$edit_img = $list[$i]['wr_content'];
if (eregi("data/cheditor4/{$ym}/[^<>]*\.(gif|jpg|png|bmp)", $edit_img, $tmp)) { // data/geditor------
$file = './' . $tmp[0]; // 파일명
$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
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면...
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
}
if (file_exists($thumb))
$thumfile = "<td width='{$img_width}' valign='top'><a href='{$list[$i][href]}'><img src='{$thumb}' width='{$img_width}' height='{$img_height}' border='0' style='border:1px #ccc solid' alt=''></a><td width='10'></td>";
else
//이미지가 없으면...
$thumfile="<td width='5'></td><td>";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file))
{ $thumfile = "<script>doc_write(flash_movie('$file', 'flash$i', '$img_width', '$img_height', 'transparent'));</script>"; }
?>
<?=$thumfile?>
</td>
<td height="<?=$img_height+5?>" valign="top" style="color:#777;"><? if (!file_exists($thumb)) { ?><?=cut_str(strip_tags($list[$i][wr_content]),950,"...")?><? } else { ?><?=cut_str(strip_tags($list[$i][wr_content]),700,"...")?><? } ?></td>
<td width="5"></td>
</tr>
</table>
<?
echo "<img src='{$latest_skin_path}/img/icon_li.gif' width='16' height='9' alt=''> <B><a href='{$list[$i][href]}' style='color:#333; text-decoration:none;'>{$list[$i][subject]}</a></B>";
echo "</div>";
}
?>
<div class="r_latest_line"></div>
<div id="r_number_wrap">
<? for ($i=0; $i<count($list); $i++) {
$k = $i + 1;
?>
<a href="<?=$list[$i][href]?>" onmouseover="javascript:ComeonF('<?=$k?>')"><img src="<?=$latest_skin_path?>/img/<?=$k?>_on.gif" width="17" height="13" border="0" alt="" id="debate_F<?=$k?>" onmouseover="clearInterval_best()" onmouseout="setInterval_best()" <? if($k == "1") { echo ""; } else { echo "style='display:none;' "; } ?>><img src="<?=$latest_skin_path?>/img/<?=$k?>.gif" width="17" height="13" border="0" alt="" id="debate_F<?=$k?>#1" <? if($k == "1") { echo "style='display:none;'"; } else { echo ""; } ?>></a>
<? } ?>
</div>
</td>
</tr>
</table>
댓글 전체
id값을 달리해서 만드셍