그누보드4 alert 함수를 튜닝해서 sweetalert로 교체하는 작업 중인데

그누보드4 alert 함수를 튜닝해서 sweetalert로 교체하는 작업 중인데

QA

그누보드4 alert 함수를 튜닝해서 sweetalert로 교체하는 작업 중인데

본문

그누보드4 alert 함수를 튜닝해서 sweetalert로 교체하는 작업 중인데 

 

function alert($msg='', $url='')

{

global $g4;

 

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

 

//header("Content-Type: text/html; charset=$g4[charset]");

echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=$g4[charset]\">";

//echo "<script language='javascript'>alert('$msg');";

    if (!$url)

echo "<script language='javascript'>swal( {title:'$msg'},function(){ history.go(-1); } );</script>";

  

    if ($url)

        // 4.06.00 : 불여우의 경우 아래의 코드를 제대로 인식하지 못함

        //echo "<meta http-equiv='refresh' content='0;url=$url'>"; 

        //goto_url($url);

echo "<script language='javascript'>swal( {title:'$msg'},function(){ location.replace('$url'); } );</script>";

    exit;

}

 

head.sub.php 쪽에 <script src="/assets/plugins/sweetalert.min.js"></script> 추가하고 사용하려고 하니

html 코드 없이 head, tail 없는 php만 있는곳에서는 오류가 나버리더군요.

 

그래서 

 function alert($msg='', $url='')

{

global $g4;

 

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

 

//header("Content-Type: text/html; charset=$g4[charset]");

echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=$g4[charset]\">";

 

echo '<body>';

echo '<script src="/assets/plugins/sweetalert.min.js"></script>';

echo '<link rel="stylesheet"  href="/assets/plugins/sweetalert.css">';

 

//echo "<script language='javascript'>alert('$msg');";

    if (!$url)

echo "<script language='javascript'>swal( {title:'$msg'},function(){ history.go(-1); } );</script>";

  

    if ($url)

        // 4.06.00 : 불여우의 경우 아래의 코드를 제대로 인식하지 못함

        //echo "<meta http-equiv='refresh' content='0;url=$url'>"; 

        //goto_url($url);

echo "<script language='javascript'>swal( {title:'$msg'},function(){ location.replace('$url'); } );</script>";

    exit;

}

 

그래서 임시로 나마 저렇게 코드를 추가 시켜서 실행시켰는데 더 좋은 방법이 있을까요?

이 질문에 댓글 쓰기 :

답변 1

답변을 작성하시기 전에 로그인 해주세요.
전체 124,109 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT