'JAVASCRIPT'에 해당되는 글 27건

  1. 2008.10.13 오른쪽 마우스 제안
  2. 2008.09.29 javascript parseInt()
  3. 2008.09.25 마우스 움직일때 Banner이동
  4. 2008.09.25 javascript slice() 함수
  5. 2008.09.22 검색 추가,삭제 버튼 이벤트
  6. 2008.09.20 javascript encoding
  7. 2008.09.12 현재 Url 가져오기
posted by 준치 2008. 10. 13. 16:21
// 오른마우스 금지, 나중에 해당 주석 풀고 사용
function rightbutton(e)
{
 if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
 return false;
 else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3))
 {
  alert("죄송합니다!! 정보무단복제를 막기 위하여 오른쪽 마우스 사용을 허용하지 않습니다.");
  return false;
 }
  return true;
}
//document.onmousedown=rightbutton; // 컨트롤 키 금지, 나중에 해당 주석 풀고 사용
posted by 준치 2008. 9. 29. 15:54

javascript parseInt 는 원래 parseInt(string, radix) 로 주어야 된다.
radix 를 주지 않으면 자동으로 찾아낼려고 시도를 하는데,

1-9 로 시작하면 10진법
0x 로 시작하면 16진법
0 으로 시작하면 8진법으로 이해한다.

8진법에서는 08, 09 가 없기 때문에.

parseInt("08") 을 하면 0이 나오게 된다.

posted by 준치 2008. 9. 25. 19:41

음...쇼핑몰에 마우스 움직일때 Banner가 같이 움직인다..많이 있다는데 그래도 같이 알면 좋잖아여..ㅎㅎ

웹페이지에서 div로 감싸서 사용해야하고 밑에 소스는 오픈될때부터 호출하면 된다...ㅎㅎㅎ
<div id="divMenu" style="right: 0%; WIDTH:210px; position: absolute; HEIGHT:172px">
움직일 테이블
</div>

var bNetscape4plus = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "4");
var bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");

var topValue = 18;
var startBannerValue = topValue + 80;

function MoveElements()
{
 var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;

 if ( bNetscape4plus )
 {
  yMenuFrom   = document["divMenu"].top;
  yMenuTo     = top.pageYOffset + topValue;   //배너의 top 위치 지정
 }
 else if ( bExplorer4plus )
 {
  yMenuFrom   = parseInt (divMenu.style.top, 10);
  yMenuTo     = document.body.scrollTop + topValue; //배너의 top 위치 지정
 }

 timeoutNextCheck = 100;

 if ( Math.abs (yButtonFrom - (yMenuTo + 152)) < 6 && yButtonTo < yButtonFrom )
 {
  setTimeout ("MoveElements()", timeoutNextCheck);
  return;
 }


 if ( yButtonFrom != yButtonTo )
 {
  yOffset = Math.ceil( Math.abs( yButtonTo - yButtonFrom ) / 10 );
  if ( yButtonTo < yButtonFrom )
          yOffset = -yOffset;

  if ( bNetscape4plus )
          document["divLinkButton"].top += yOffset;
  else if ( bExplorer4plus )
          divLinkButton.style.top = parseInt (divLinkButton.style.top, 10) + yOffset;

  timeoutNextCheck = 10;
 }
 if ( yMenuFrom != yMenuTo )
 {
  yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 20 );
  if ( yMenuTo < yMenuFrom )
          yOffset = -yOffset;

  if ( bNetscape4plus )
          document["divMenu"].top += yOffset;
  else if ( bExplorer4plus )
          divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;

  timeoutNextCheck = 10;
 }

 setTimeout ("MoveElements()", timeoutNextCheck);
}

function StartBanner()
 {
  var y;
 
  if( bNetscape4plus )
  {
   document["divMenu"].top = top.pageYOffset + startBannerValue;
   document["divMenu"].visibility = "visible";
  }
  else if( bExplorer4plus )
  {
   divMenu.style.top = document.body.scrollTop + startBannerValue;
   divMenu.style.visibility = "visible";
  }

  MoveElements();
  return true;
 }

posted by 준치 2008. 9. 25. 15:10
찾다보니 나와서 올려..slice(시작,끝) 이렇게 사용하네..간단 예제...

<script type="text/javascript">
    var str="abcdef";
    alert(str.slice(2,4));
</script>

결과 cd 이렇게 나온다.
posted by 준치 2008. 9. 22. 15:00
검색 추가 버튼 클릭시 그냥 돌려서 보여주고 안보여주고...그냥..뭐...

//추가 함수
function addSearchArea()
{
 var disType; 
 for(var i = 1; i < 5; i++)
 {  
  disType = document.getElementById('SearchArea_' + i).style.display
  if(disType == "none")
  {
   document.getElementById('SearchArea_' + i).style.display = "block";
   break;
  }
 }
}

//줄이기 버튼
function SearchArea()
{
 var controlID = "ctl00_PlaceHolderMain_EzNetWebpart_";
 var disType;
 var disTxtType;
 for(var i = 4; i > 0; i--)
 {  
  disType = document.getElementById('SearchArea_' + i).style.display;
  
  if(disType == "block")
  {
   document.getElementById(controlID + 'SearchText_' + i).value = "";
   document.getElementById('SearchArea_' + i).style.display = "none";   
   break;
  }
 }
}
posted by 준치 2008. 9. 20. 16:55

현재 까지 써본것은 escape 와 unescape 함수인데 다른 값으로 변경되는 경우가 있어서
다른것은 테스트 해보려한다..ㅎㅎㅎ

* encodeURI() : decodeURI()
* encodeURIComponent() : decodeURIComponent()
* escape() : unescape()

테스트 결과 sharepoint SearchServer에서는 encodeURI 이 함수를 쓴다
밑에 소스 str에 원하는 한글을 넣으면 된다..ㅎㅎㅎ

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>
 <script language="javascript">
 function change(str)
 {
document.write("-----encodeURI </br>");
document.write(encodeURI(str));
document.write("</br>");
document.write("-----decodeURI </br>");
document.write(decodeURI(str));
document.write("</br>");
document.write("----encodeURIComponent </br>");
document.write(encodeURIComponent(str));
document.write("</br>");
document.write("----decodeURIComponent </br>");
document.write(decodeURIComponent(str));
document.write("</br>");
document.write("----escape </br>");
document.write(escape(str));
document.write("</br>");
document.write("----unescape </br>");
document.write(unescape(str));

}
 </script>
 <BODY>
  <input type="button" value="button" onclick="change('인사')">
 </BODY>
</HTML>

posted by 준치 2008. 9. 12. 01:48

현재 url을 가져오기 간단하지만 자꾸 잊어서 올려요..ㅎㅎ

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
  <script>
function url()
{
 alert(document.location.href);   //요기 ㅋㅋㅋ
}
  </script>
 </HEAD>

 <BODY>
  <input type="button" text="button" onclick="url()">
 </BODY>
</HTML>