CI 묻고 답하기

제목 show_error메세지 이후
글쓴이 GunENE 작성시각 2011/02/16 10:50:13
댓글 : 1 추천 : 0 스크랩 : 0 조회수 : 29410   RSS
show_error로 메세지를 뛰운다음에
자동으로 이전페이지로 가는 건 어떻게 하나요?
redirect로 해봤는데 안되고

자바스크립트의 alert처럼 메세지 뛰우고 확인 누르면 history.back하는건 없나요?
되도록이면 show_error메세지로 뛰우고 버튼 만들어서 뒤로가게 하고 싶은데요..
 다음글 form에서 set_value로 value 복원시 한글... (2)
 이전글 코드이그나이터로 만든 프로그램을 GPL로 배포하는 것이... (1)

댓글

변종원(웅파) / 2011/02/16 14:25:04 / 추천 0
application/errors/ 디렉토리안의 error_404.php 파일에 back 버튼 달아보세요.

팁게시판 보시면 ci사랑님이 올려놓으신 alert helper가 있을겁니다.
그게 원하시는 역할을 해주는 헬퍼입니다.
//application/helpers/alert_helper.php

<? if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// 경고메세지를 경고창으로
function alert($msg='', $url='') {
	$CI =& get_instance();

	if (!$msg) $msg = '올바른 방법으로 이용해 주십시오.';

	echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=".$CI->config->item('charset')."\">";
	echo "<script type='text/javascript'>alert('".$msg."');";
    if ($url)
        echo "location.replace('".$url."');";
	else
		echo "history.go(-1);";
	echo "</script>";
	exit;
}

// 경고메세지 출력후 창을 닫음
function alert_close($msg) {
	$CI =& get_instance();

	echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=".$CI->config->item('charset')."\">";
	echo "<script type='text/javascript'> alert('".$msg."'); window.close(); </script>";
	exit;
}

// 경고메세지만 출력
function alert_only($msg) {
	$CI =& get_instance();

	echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=".$CI->config->item('charset')."\">";
	echo "<script type='text/javascript'> alert('".$msg."'); </script>";
	exit;
}

function alert_continue($msg){
	$CI =& get_instance();

	echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=".$CI->config->item('charset')."\">";
	echo "<script type='text/javascript'> alert('".$msg."'); </script>";	
}
?>