본문 바로가기

스크립트/윈도우창관련

여려가지 유용한 스크립트 모음

여려가지 유용한 스크립트 모음




/* 링크 점선 제거 */

function bluring(){
 if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
//document.onfocusin=bluring;


// flashWrite(파일경로, 가로, 세로, 아이디, 배경색, 변수, 윈도우모드)
function flashWrite(url,w,h,id,bg,vars,win){

 // 플래시 코드 정의
 var flashStr=
 "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
 "<param name='allowScriptAccess' value='always' />"+
 "<param name='movie' value='"+url+"' />"+
 "<param name='FlashVars' value='"+vars+"' />"+
 "<param name='wmode' value='"+win+"' />"+
 "<param name='wmode' value='opaque'>"+
 "<param name='menu' value='false' />"+
 "<param name='quality' value='high' />"+
 "<param name='bgcolor' value='"+bg+"' />"+
 "<param name='wmode' value='transparent'>"+
 "<embed src='"+url+"' FlashVars='"+vars+"' wmode='"+win+"' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' value='opaque' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
 "</object>";

 // 플래시 코드 출력
 document.writeln(flashStr);

}
//동영상
function aviPlay(src,w,h) {
document.writeln('<embed src="'+src+'" width='+w+' height='+h+' style="FILTER:xray">')
}

//예시 <script>flashWrite('./image/swf/sub1.swf','100%','300','sub1','#ffffff','','transparent')</script>

 

//팝업 코드 링크시 예시 href="javascript:new_window('win', '파일명', 좌, 상, 가로, 세로, 0, 0, 0, 0, 0);"

function newWin(page,name,w,h,scroll) {

 LeftPosition = (screen.width)?(screen.width-w)/2:100;
 TopPosition  = (screen.height)?(screen.height-h)/2:100;

 settings  = 'width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',status=no';

 mywin = window.open(page,name,settings);
 mywin.self.focus();

}


// 롤오버
function MM_swapImgRestore() { //v3.0
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}
function MM_findObj(n, d) { //v4.01
 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 if(!x && d.getElementById) x=d.getElementById(n); return x;}
function MM_swapImage() { //v3.0
 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}

// 점프메뉴 //
function MM_jumpMenu(targ,selObj,restore){ //v3.0
 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
 if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu2(targ,selObj,restore){ //v3.0
window.open(selObj.options[selObj.selectedIndex].value,"");
}


// 메인 최근글 관련
function MM_reloadPage(init) { //reloads the window if Nav4 resized
 if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
  document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
 else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
 var i,p,v,obj,args=MM_showHideLayers.arguments;
 for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
  if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
  obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

 

<!--즐겨찾기 스크립트
function bookmark(){
window.external.AddFavorite('http://, '하하하하 사이트 ')
}

/* 레이어 팝업 */
function popupLayer(s,w,h){
 if (!w) w = 980;
 if (!h) h = 700;

 var pixelBorder = 5;
 var titleHeight = 5;
 w += pixelBorder * 2;
 h += pixelBorder * 2 + titleHeight;

 var bodyW = document.body.clientWidth;
 var bodyH = document.body.clientHeight;

 var posX = (bodyW - w) / 2;
 var posY = (bodyH - h) / 2;

 hiddenSelectBox('hidden');

/* 백그라운드 레이어 */
 var obj = document.createElement("div");
 with (obj.style){
  position = "absolute";
  zIndex =2;
  left = 0;
  top = 0;
  height = document.body.scrollHeight;
  width= document.body.clientWidth;
  backgroundColor = "#000000";
  filter = "Alpha(Opacity=65)";
  opacity = "0.5";
 }
 obj.id = "objPopupLayerBg";
 document.body.appendChild(obj);

/* 내용 */
 var obj = document.createElement("div");
 with (obj.style){
  position = "absolute";
  zIndex = 3;
  left = posX + document.body.scrollLeft;
  top = posY + document.body.scrollTop;
  width = w;
  height = h;
  backgroundColor = "#ffffff";
  border = "5px solid #000000";
 }
 obj.id = "objPopupLayer";
 document.body.appendChild(obj);

/* 닫기버튼 레이어 */
 var bottom = document.createElement("div");
 with (bottom.style){
  position = "absolute";
  zIndex = 2;
  width = w - pixelBorder * 2+7;
  height = titleHeight;
  left = 0;
  top =0;
  padding = "3px 0 2px 0";
  textAlign = "right";
  backgroundColor = "#000000";
  color = "#000000";
 }
 bottom.innerHTML = "<a href='/travel/print.htm' target='_blank'><img src='/images/common/gall_print.gif' border='0'/></a>&nbsp;<a href='javascript:closeLayer()'><img src='/images/common/gall_close.gif' border='0'/></a>&nbsp;&nbsp;&nbsp;";
 obj.appendChild(bottom);

/* 아이프레임 */
 var ifrm = document.createElement("iframe");
 with (ifrm.style){
  width = w - 6;
  height = h - pixelBorder * 2 - titleHeight+8;
  border = "0 solid #000000";
 }
 ifrm.frameBorder = 0;
 ifrm.src = s;
 ifrm.className = "scroll";
 obj.appendChild(ifrm);
}

function _ID(obj){
 return document.getElementById(obj)
}

function hiddenSelectBox(mode){
 var obj = document.getElementsByTagName('select');
 for (i=0;i<obj.length;i++){
  obj[i].style.visibility = mode;
 }
}

function closeLayer(){
 hiddenSelectBox('visible');
 _ID('objPopupLayer').parentNode.removeChild( _ID('objPopupLayer') );
 _ID('objPopupLayerBg').parentNode.removeChild( _ID('objPopupLayerBg') );
}
function gallview(){
 popupLayer("/travel/map.htm", 980, 700);
}