채택완료

모바일에서는 팝업이 안뜨게 하기

2018-07-20 (금) 11:40:54 3,070

컴퓨터에서는 뜨고 모바일에서는 팝업이 안뜨게 하는 방법이 있나요?

고수님들 부탁드립니다.

http://wappleedu.com

답변 5개 / 댓글 2개

채택된 답변
+20 포인트

스크립트에  

 if ( getCookie( "Notice[1]" ) != "done[1]" ){
window.open ('pop1.html','english1','left=500,top=112,width=800, height=848,scrollbars=no,toolbars=no,resizable=0');   
} 가 위에 한번 아래에 한번 이렇게 2개가 있어서 그럽니다.

head 안에 있는 script 부분 삭제하시고

아래의 스크립트만 넣어세요...

Copy
<SCRIPT language=javascript>
<!--
function getCookie( name ){
   var nameOfCookie = name + "=";
   var x = 0;
   while ( x <= document.cookie.length ){
        var y = (x+nameOfCookie.length);
        if ( document.cookie.substring( x, y ) == nameOfCookie ) {
             if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                  endOfCookie = document.cookie.length;
             return unescape( document.cookie.substring( y, endOfCookie ) );
        }
        x = document.cookie.indexOf( " ", x ) + 1;
        if ( x == 0 )
            break;
    }
return "";
}

var filter = "win16|win32|win64|mac";
if(navigator.platform){
    if(0 > filter.indexOf(navigator.platform.toLowerCase())){
        // mobile
    }else{
        // pc
        if ( getCookie( "Notice[1]" ) != "done[1]" ){
          window.open ('pop1.html','english1','left=500,top=112,width=800, height=848,scrollbars=no,toolbars=no,resizable=0');   
            }
    }
}
//-->
</SCRIPT>

 

index 페이지를 열어보시면 팝업을 띄우는 스크립트 구문이 있습니다.

if ( getCookie( "Notice[1]" ) != "done[1]" ){
    window.open ('pop1.html','english1','left=500,top=112,width=800, height=848,scrollbars=no,toolbars=no,resizable=0');   
}

여기를 DEVICE 가 모바일인지 피씨인지 구분해서 실행하도록 하게 하면 됩니다.

EX)

Copy
<script type="text/javascript">

var filter = "win16|win32|win64|mac";

if(navigator.platform){
    if(0 > filter.indexOf(navigator.platform.toLowerCase())){
        // mobile
    }else{
        // pc
        if ( getCookie( "Notice[1]" ) != "done[1]" ){
          window.open ('pop1.html','english1','left=500,top=112,width=800, height=848,scrollbars=no,toolbars=no,resizable=0');   
            }
    }
}
</script>

답변에 대한 댓글 1개

2018-07-20 (금) 13:15:11
주신소스로 수정했는데요 모바일에서 열립니다.
도와주세요 예를들어 네이버 앱에서 와플에듀 검색해서 클릭하면
팝업때문에 방해가됩니다.
2018-07-20 (금) 11:52:20

팝업파일명이 pop1.html이고 index.html에 연결되어 있습니다.

2018-07-20 (금) 11:50:01

PHP가 아닌데요 고수님

답변에 대한 댓글 1개

아 그누보드가 아니군요 ㅜㅜ

head.php 파일  상단에 아래와 같이 해보세요

    <?php
    if(defined('_INDEX_') && G5_IS_MOBILE == false) { // index에서만 실행
        include G5_BBS_PATH.'/newwin.inc.php'; // 팝업레이어
    }
    ?>

답변을 작성하려면 로그인이 필요합니다.