캠핑과 개발

contextmenu="return false"       우클릭 방지
ondragstart="return false"         드래그 방지
onselectstart="return false"       선택 방지


<HTML>

<body  oncontextmenu="return false" ondragstart="return false" onselectstart="return false">

내용

</body>

</HTML>


'DEVELOPMENT > Javascript' 카테고리의 다른 글

var 키워드의 변수 범위  (0) 2016.06.01
javascript grap library  (0) 2014.03.06
[Android]app <---> javascript 통신  (0) 2011.04.18
[jquery] ajax 사용하기  (0) 2010.12.17
javascript 정리  (0) 2010.12.17

ajax 쌩으로 쓸려면 코드도 길어지고 xmlhttp 객체 메모리관리도 해야하고 이것저것 귀찮죠
jquery 에서는 상당히 심플한 인터페이스를 제공합니다.. 플젝하다가 갖다썼는데 상당히 만족스럽네요
여러가지 ajax 타입을 소개할까합니다. 재밌는것도 몇개있네요.

타입1.

$.ajax({
  type: "GET",
  url: "test.js",
  dataType: "script"
});

기본형을 보시면 ajax() 라는 메서드안에 속성 3개를 가진 객체를 생성한후 인자로 때려넣고 있군요.
동적으로 js파일을 로드해서 실행시키는 기능을합니다. 기능이 재밌어 보이긴하는데, 실제로 별로 안쓸것같네요 -_-;


타입2.

 $.ajax({
   type: "POST",
   url: "some.php",
   data: "name=John&location=Boston",
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
});
some.php 에 POST 타입으로 name 과 location 을 parameter 로 넘기고있네요. success 프라퍼티는 서버에서 http response 를 받은후에 수행될 콜백함수를 지정합니다. "데이타가 저장되었어염" 라고 알려주네요.
갠적으로 이 타입을 가장많이 사용하고있습니다. 실무에서도 가장많이 사용되죠.

타입3.
$.ajax({
  url: "test.html",
  cache: false,
  success: function(html){
    $("#results").append(html);
  }
});
cache 라는 프라퍼티가 추가되었군요. test.html 을 가장 최근에 수정된 페이지로 받겠다는거죠.
"캐쉬를 사용하지 않겠다" 이겁니다. html 을 받은후에 results라는 아이디를 가진 엘리먼트의 자식노드로써 추가하고있네요. 쌩 dom api 로 쓰면 이렇겠죠. document.getElementById("results").innerHTML = html;
음 근데 이거랑은 좀 차이점이있어요. append 는 "result 엘리먼트의 자식이 존재할경우, 가장 마지막 자식으로 붙인다" 라는 규칙을 가지고있거든요. 반면에 innerHTML 으로넣으면 자식이 존재하든안하든 덮어써버리는거죠. 기존의 html 엘리먼트는 사라지고 새로운 엘리먼트로 교체되는 개념입니다.

타입4.
 var html = $.ajax({
  url: "some.php",
  async: false
}).responseText;
async(비동기) 라는 프라퍼티가 추가되었군요. false를 때려넣었으니까 "동기"로 요청한다는말이네요.
뭔말이냐면, some.php로 request를 날린후에 response가 오기전까지는 브라우저를 블락킹 시켜버립니다.
유저의 어떠한 인터렉션도 허용되지않죠. 보시면 콜백함수를 때려넣는 success라는 프라퍼티도없네요
그럼 어떻게 응답데이타를 받나염? 바로 저렇게요. var html = $.ajax().responseText;
어차피 서버로부터 response 가 오기전까지는 스크립트수행이 블락되어있으니까 저 코드가 가능한겁니다.
웹플밍을 하다보면 이 타입을 "써야만" 할때가 종종있더군요.

타입 5.
 var xmlDocument = [create xml document];
$.ajax({
   url: "page.php",
   processData: false,
   data: xmlDocument,
   success: handleResponse
});


출처 : http://boast.tistory.com/entry/JQuery-Ajax-사용하기


이미지 태그의 속성인 ALT 속성의 내용중에 많은 양이 있을 경우 줄바꿈을 해야 되는 경우가 있다 그럴때 &#13; 를 사용하면 된다..

<IMG SRC="image.gif" alt="보통 이미지 입니다. &#13; 보통 이미지 입니다." />

'DEVELOPMENT > HTML & CSS' 카테고리의 다른 글

[canvas] 2D를 이용한 객체 회전  (0) 2016.06.01
[canvas] 키보드를 이용한 객체 이동  (0) 2016.06.01
CSS framework  (0) 2014.01.17
DOCTYPE.  (0) 2009.10.28
CSS 작성 기초 - 선택자 사용하기  (0) 2009.10.28

특정 사이트를 즐겨찾기에 추가하는 방법임다..
굳이 설명이 필요 없으리라..

<html>
<head>
 <title>즐겨찾기 추가</title>
 <script language="javascript">
 /**
 * 해당 사이트를 즐겨찾기에 추가한다.
 * 이 스크립트를 사용하기 위해서는 각 브라우저마다 기능 여부를 체크후에 사용
 *
 **/
 function addBookMark(){
     var url = "http://hmjkor.tistory.com";
     var title = "맹돌이의 블로그입니다.";
     window.external.AddFavorite(url, title);
 }
 </script>
</head>
<body>
    <a href="javascript:addBookMark();">즐겨찾기 추가</script>
</body>
</html>


브라우저의 주소창이나 탭, 즐겨찾기에 사이트만의 특정 로고나 이미지를 삽입하는 방법이다.



1. favicon.ico 제작

먼저 사용될 favicon 아이콘을 제작한다.
사이즈는 16*16, 32*32, 48*48로 제작
jpg,gif,png 등의 파일을 사이즈에 맞게 제작을 하여 파일명은 favicon, 확장자는 ico 확장자로 변경한다. 직접 제작을 해도 되나 그러지 못한 경우는 검색해보면 많이 나오니 찾아서 제작
하나 추천 : http://www.html-kit.com/favicon

2. html 페이지 코드 삽입
 
만들어진 favicon.ico를 WebRoot 하위에 업로드 함
index 페이지에 다음 코드를 삽입

방법 1

<html>
<head>
    <title>favicon</title>
     <link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>
</body>
</html>

방법 2
<html>
<head>
    <title>favicon</title>
    <link rel="icon" href="/favicon.ico" type="image/x-icon" />
   <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
</head>
<body>
</body>
</html>


이미지가에 문제가 있는경우는 나타나지 않을 수도 있다.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
 <TITLE> New Document </TITLE>
 <script language="JavaScript" type="text/javascript">
 <!--
 var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
 
 /**
 * option 추가
 **/
 function addOption(theSel, theText, theValue){
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
 }
 /**
 * option 삭제
 **/
 function deleteOption(theSel, theIndex){
  var selLength = theSel.length;
  if(selLength>0){
   theSel.options[theIndex] = null;
  }
 }
 
 /**
 * option 삭제
 **/
 function moveOptions(theSelFrom, theSelTo){
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--){
   if(theSelFrom.options[i].selected){
    selectedText[selectedCount] = theSelFrom.options[i].text;
    selectedValues[selectedCount] = theSelFrom.options[i].value;
    deleteOption(theSelFrom, i);
    selectedCount++;
   }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--){
   addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  
  if(NS4) history.go(0);
 }
 //-->
 </script>
 </HEAD>
 <BODY>
<form action="yourpage.asp" method="post">
<table border="0">
 <tr>
  <td>
   <select name="sel1" size="10" multiple="multiple">
   <option value="1">Left1</option>
   <option value="2">Left2</option>
   <option value="3">Left3</option>
   <option value="4">Left4</option>
   <option value="5">Left5</option>
   </select>
  </td>
  <td align="center" valign="middle">
   <input type="button" value="--&gt;"
    onclick="moveOptions(this.form.sel1, this.form.sel2);" /><br />
   <input type="button" value="&lt;--"
    onclick="moveOptions(this.form.sel2, this.form.sel1);" />
  </td>
  <td>
   <select name="sel2" size="10" multiple="multiple">
   <option value="1">Right1</option>
   <option value="2">Right2</option>
   <option value="3">Right3</option>
   <option value="4">Right4</option>
   <option value="5">Right5</option>
   </select>
  </td>
 </tr>
</table>
</form>
 </BODY>
</HTML>

출처 : http://www.mredkj.com/tutorials/tutorial_mixed2b.html


<!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 language="JavaScript" type="text/javascript">
 <!--
 var count1 = 0;
 var count2 = 0;
 /**
 * 선택된 option의 이전에 새로운 option 을 추가한다.
 **/
 function insertOptionBefore(num){
  var elSel = document.getElementById('selectX');
  if(elSel.selectedIndex >= 0) {
   var elOptNew = document.createElement('option');
   elOptNew.text = 'Insert' + num;
   elOptNew.value = 'insert' + num;
   var elOptOld = elSel.options[elSel.selectedIndex]; 
   try {
    elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE
   }catch(ex){
    elSel.add(elOptNew, elSel.selectedIndex); // IE only
   }
  }
 }
 /**
 * 선택된 옵션을 삭제한다.
 **/
 function removeOptionSelected(){
  var elSel = document.getElementById('selectX');
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
   if (elSel.options[i].selected) {
    elSel.remove(i);
   }
  }
 }
 /**
 * 마지막에 새로운 option을 추가한다.
 **/
 function appendOptionLast(num){
  var elOptNew = document.createElement('option');
  elOptNew.text = 'Append' + num;
  elOptNew.value = 'append' + num;
  var elSel = document.getElementById('selectX');
  try {
   elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }catch(ex) {
   elSel.add(elOptNew); // IE only
  }
 }
 /**
 * 마지막 옵션을 삭제한다.
 **/
 function removeOptionLast(){
  var elSel = document.getElementById('selectX');
  if (elSel.length > 0){
   elSel.remove(elSel.length - 1);
  }
 }
 //-->
 </script>
 </HEAD>
<BODY>
<form>
 <input type="button" value="이전 추가" onclick="insertOptionBefore(count1++);" />Insert Before Selected<br />
 <input type="button" value="삭제" onclick="removeOptionSelected();" />Remove Selected<br />
 <select id="selectX" size="10">
  <option value="original1" selected="selected">Orig1</option>
  <option value="original2">Orig2</option>
 </select>
 <br />
 <input type="button" value="마지막 추가" onclick="appendOptionLast(count2++);" />Append Last<br />
 <input type="button" value="마지막 삭제" onclick="removeOptionLast();" />Remove Last
</form>
</BODY>
</HTML>

표현문자

숫자표현

문자표현

설명

-

&#00;-&#08;

-

사용하지 않음

space

&#09;

-

수평탭

space

&#10;

-

줄 삽입

-

&#11;-&#31;

-

사용하지 않음

space

&#32;

-

여백

!

&#33;

-

느낌표

"

&#34;

&quot;

따옴표

#

&#35;

-

숫자기호

$

&#36;

-

달러

%

&#37;

-

백분율 기호

&

&#38;

&amp;

Ampersand

'

&#39;

-

작은 따옴표

(

&#40;

-

왼쪽 괄호

)

&#41;

-

오른쪽 괄호

*

&#42;

-

아스트릭

+

&#43;

-

더하기 기호

,

&#44;

-

쉼표

-

&#45;

-

Hyphen

.

&#46;

-

마침표

/

&#47;

-

Solidus (slash)

0 - 9

&#48;-&#57;

-

0부터 9까지

:

&#58;

-

콜론

;

&#59;

-

세미콜론

<

&#60;

&lt;

보다 작은

=

&#61;

-

등호

>

&#62;

&gt;

보다 큰

?

&#63;

-

물음표

@

&#64;

-

Commercial at

A - Z

&#65;-&#90;

-

A부터 Z까지

[

&#91;

-

왼쪽 대괄호

\

&#92;

-

역슬래쉬

]

&#93;

-

오른쪽 대괄호

^

&#94;

-

탈자부호

_

&#95;

-

수평선

`

&#96;

-

Acute accent

a - z

&#97;-&#122;

-

a부터 z까지

{

&#123;

-

왼쪽 중괄호

|

&#124;

-

수직선

}

&#125;

-

오른쪽 중괄호

~

&#126;

-

꼬리표

-

&#127;-&#159;

-

사용하지 않음

&#160;

&nbsp;

Non-breaking space

¡

&#161;

&iexcl;

거꾸로된 느낌표

&#162;

&cent;

센트 기호

&#163;

&pound;

파운드

¤

&#164;

&curren;

현재 환율

&#165;

&yen;

|

&#166;

&brvbar;

끊어진 수직선

§

&#167;

&sect;

섹션 기호

¨

&#168;

&uml;

움라우트

&#169;

&copy;

저작권

ª

&#170;

&ordf;

Feminine ordinal

&#171;

&laquo;

왼쪽 꺾인 괄호

&#172;

&not;

부정

­

&#173;

&shy;

Soft hyphen

?

&#174;

&reg;

등록상표

&hibar;

&#175;

&macr;

Macron accent

°

&#176;

&deg;

Degree sign

±

&#177;

&plusmn;

Plus or minus

²

&#178;

&sup2;

Superscript two

³

&#179;

&sup3;

Superscript three

´

&#180;

&acute;

Acute accent

μ

&#181;

&micro;

Micro sign (Mu)

&#182;

&para;

문단기호

·

&#183;

&middot;

Middle dot

¸

&#184;

&cedil;

Cedilla

¹

&#185;

&sup1;

Superscript one

º

&#186;

&ordm;

Masculine ordinal

&#187;

&raquo;

오른쪽 꺾인 괄호

¼

&#188;

&frac14;

4분의 1

½

&#189;

&frac12;

2분의 1

¾

&#190;

&frac34;

4분의 3

¿

&#191;

&iquest;

거꾸로된 물음표

A

&#192;

&Agrave;

Capital A, grave accent

A

&#193;

&Aacute;

Capital A, acute accent

A

&#194;

&Acirc;

Capital A, circumflex accent

A

&#195;

&Atilde;

Capital A, tilde

A

&#196;

&Auml;

Capital A, dieresis or umlaut mark

A

&#197;

&Aring;

Capital A, ring (Angstrom)

Æ

&#198;

&AElig;

Capital AE diphthong (ligature)

C

&#199;

&Ccedil;

Capital C, cedilla

E

&#200;

&Egrave;

Capital E, grave accent

E

&#201;

&Eacute;

Capital E, acute accent

E

&#202;

&Ecirc;

Capital E, circumflex accent

E

&#203;

&Euml;

Capital E, dieresis or umlaut mark

I

&#204;

&Igrave;

Capital I, grave accent

I

&#205;

&Iacute;

Capital I, acute accent

I

&#206;

&Icirc;

Capital I, circumflex accent

I

&#207;

&Iuml;

Capital I, dieresis or umlaut mark

Ð

&#208;

&ETH;

Capital Eth, Icelandic

N

&#209;

&Ntilde;

Capital N, tilde

O

&#210;

&Ograve;

Capital O, grave accent

O

&#211;

&Oacute;

Capital O, acute accent

O

&#212;

&Ocirc;

Capital O, circumflex accent

O

&#213;

&Otilde;

Capital O, tilde

O

&#214;

&Ouml;

Capital O, dieresis or umlaut mark

×

&#215;

&times;

Multiply sign

Ø

&#216;

&Oslash;

width="130"Capital O, slash

U

&#217;

&Ugrave;

Capital U, grave accent

U

&#218;

&Uacute;

Capital U, acute accent

U

&#219;

&Ucirc;

Capital U, circumflex accent

U

&#220;

&Uuml;

Capital U, dieresis or umlaut mark

Y

&#221;

&Yacute;

Capital Y, acute accent

Þ

&#222;

&THORN;

Capital Thorn, Icelandic

ß

&#223;

&szlig;

Small sharp s, German (sz ligature)

a

&#224;

&agrave;

Small a, grave accent

a

&#225;

&aacute;

Small a, acute accent

a

&#226;

&acirc;

Small a, circumflex accent

a

&#227;

&atilde;

Small a, tilde

a

&#228;

&auml;

Small a, dieresis or umlaut mark

a

&#229;

&aring;

Small a, ring

æ

&#230;

&aelig;

Small ae diphthong (ligature)

c

&#231;

&ccedil;

Small c, cedilla

e

&#232;

&egrave;

Small e, grave accent

e

&#233;

&eacute;

Small e, acute accent

e

&#234;

&ecirc;

Small e, circumflex accent

e

&#235;

&euml;

Small e, dieresis or umlaut mark

i

&#236;

&igrave;

Small i, grave accent

i

&#237;

&iacute;

Small i, acute accent

i

&#238;

&icirc;

Small i, circumflex accent

i

&#239;

&iuml;

Small i, dieresis or umlaut mark

ð

&#240;

&eth;

Small eth, Icelandic

n

&#241;

&ntilde;

Small n, tilde

o

&#242;

&ograve;

Small o, grave accent

o

&#243;

&oacute;

Small o, acute accent

o

&#244;

&ocirc;

Small o, circumflex accent

o

&#245;

&otilde;

Small o, tilde

o

&#246;

&ouml;

Small o, dieresis or umlaut mark

÷

&#247;

&divide;

Division sign

ø

&#248;

&oslash;

Small o, slash

u

&#249;

&ugrave;

Small u, grave accent

u

&#250;

&uacute;

Small u, acute accent

u

&#251;

&ucirc;

Small u, circumflex accent

u

&#252;

&uuml;

Small u, dieresis or umlaut mark

y

&#253;

&yacute;

Small y, acute accent

þ

&#254;

&thorn;

Small thorn, Icelandic

y

&#255;

&yuml;

Small y, dieresis or umlaut mark


매번 까먹는다.
한번 쓸때는 이제 알겠지 하면서 어제 썼던걸 오늘 또 찾게 된다.


<select id='selectbox'>
<option value="1">사과</option>
<option value="2">배</option>
<option value="3">포도</option>
<option value="4">귤</option>
<option value="5">자두</option>
</select>


text 값 가져오기
<script language="javascript">
     var obj = document.getElementById('selectbox');
     var text = obj.options[obj.selectedIndex].text;
     alert(text); 
</script>


value 값 가져오기
<script language="javascript">
var obj = document.getElementById(''selectbox'');
var value = obj.options[obj.selectedIndex].value;
alert(value);
</script>

토요일에 할일 없이 회사에 출근했다가 이러저리 돌아다니다가 좋은 사이트가 있어서 포스팅 한번 합니다.

HTML 소스를 정렬해주는 사이트입니다.
탭 들여쓰기,  자동 들여쓰기, 자동 줄바꿈 등 여러가지가 지원이 됩니다.
드림위버로 코딩이 된 소스를 보면 줄바꿈이라던가 소스 관리가 엉망인데 이 사이트에서 한번 정렬 하신후에 사용하시면 개발하기가 참 편할꺼 같네요.

URL : http://www.mycoolform.com/

'DEVELOPMENT > Javascript' 카테고리의 다른 글

[javascript] select box  (0) 2009.02.16
[HTML] 제어 문자  (0) 2009.01.16
[tip] 영문 alert 메세지  (0) 2008.09.25
javascript 디버거 툴  (0) 2008.08.18
클립보드 복사  (0) 2008.08.18