function my_popup(no) {
open("", "mypop", "width=530, height=800"); // 먼저 빈 창을 mypop 라는 이름으로 열어놓고
document.fwrite.action = "test_inp.php?no="+no; // 'test_inp.php' 를 fwrite이 실행될 action 으로 지정한다.
document.fwrite.target = "mypop"; // 이 부분이 핵심! 열어놓은 빈 창(mypop)을 fwrite이 날아갈 target으로 정한다.
document.fwrite.method = "post"; // target에 submit할 방식을 post 방식으로 지정한다.
document.fwrite.submit(); // target에 쏜다.
}
2010년 1월 29일 금요일
2009년 4월 23일 목요일
[자바스크립트] 팝업창 하루동안 띄우지 않기 소스 및 정중앙에 띄우는 방법
//하루동안 띄우지 않는 소스
팝업창 안에 들어갈 소스는 아래와 같습니다..
//실제 팝업창내의 소스
<html>
<head>
<title>http://www.blueb.co.kr</title>
<script language="JavaScript">
<!--
function notice_setCookie( name, value, expiredays )
{
var todayDate = new Date();
todayDate.setDate( todayDate.getDate() + expiredays );
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
function notice_closeWin()
{
if ( document.forms[0].Notice.checked )
notice_setCookie( "Notice", "done" , 1); // 1=하룻동안 공지창 열지 않음
self.close();
}
function na_call(str){ eval(str);}
//-->
</script>
</head>
<body>
<form name="form1">
<input type="checkbox" name="Notice" OnClick="notice_closeWin()">오늘은 이창을 다시 열지않음
</form>
</body>
</html>
<head>
<title>http://www.blueb.co.kr</title>
<script language="JavaScript">
<!--
function notice_setCookie( name, value, expiredays )
{
var todayDate = new Date();
todayDate.setDate( todayDate.getDate() + expiredays );
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
function notice_closeWin()
{
if ( document.forms[0].Notice.checked )
notice_setCookie( "Notice", "done" , 1); // 1=하룻동안 공지창 열지 않음
self.close();
}
function na_call(str){ eval(str);}
//-->
</script>
</head>
<body>
<form name="form1">
<input type="checkbox" name="Notice" OnClick="notice_closeWin()">오늘은 이창을 다시 열지않음
</form>
</body>
</html>
//본문에 해당하는 문서에 삽입될 소스
<html>
<head>
<title>http://www.blueb.co.kr</title>
<script language="JavaScript">
<!--
function notice_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 "";
}
if ( notice_getCookie( "Notice" ) != "done" )
{
window.open('http://www.blueb.co.kr/SRC/javascript/cookie_popup.html','','width=340,height=300'); // 팝업윈도우의 경로와 크기를 설정 하세요
}
// -->
</script>
</head>
<body>
팝업창을 확인하세요..
</body>
</html>
<head>
<title>http://www.blueb.co.kr</title>
<script language="JavaScript">
<!--
function notice_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 "";
}
if ( notice_getCookie( "Notice" ) != "done" )
{
window.open('http://www.blueb.co.kr/SRC/javascript/cookie_popup.html','','width=340,height=300'); // 팝업윈도우의 경로와 크기를 설정 하세요
}
// -->
</script>
</head>
<body>
팝업창을 확인하세요..
</body>
</html>
//화면 정중앙에 팝업 띄우는 소스
<script>
function popUp(w, h){
x = (screen.availWidth - w) / 2;
y = (screen.availHeight - h) / 2;
window.open('http://naver.com', 'pop','width='+w+', height='+h+', left='+x+', top='+y);
}
</script>
<body>
<a href="javascript:popUp(400, 300);">새창띄우기</a>
</body>
function popUp(w, h){
x = (screen.availWidth - w) / 2;
y = (screen.availHeight - h) / 2;
window.open('http://naver.com', 'pop','width='+w+', height='+h+', left='+x+', top='+y);
}
</script>
<body>
<a href="javascript:popUp(400, 300);">새창띄우기</a>
</body>
//팝업창 왼쪽과 위쪽에 공백이 문제시될 경우
<body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
피드 구독하기:
글 (Atom)