'자바스크립트'에 해당되는 글 2건

  1. 2011.11.04 자바스크립트 명령어
  2. 2011.11.03 자바스크립트 레퍼런스
영삼이의 IT정보2011. 11. 4. 03:58

<자바스크립트 명령어>

자바스크립트는 자료형을 쓰지않고 변수선언이 가능함
ex)
i=10
s=한글

<script language=javascript> </script> //이사이에 자바스크립트 명령어들사용

function 메서드명{} //사용자정의 메서드를 만든다

document.write() //화면에 메세지를 출력한다 (system.out.print기능)

document.write("<br>") //한줄 내린다

document.write("&nbsp") // 일정칸띄운다

prompt("메세지","기본값") // 입력창을 띄운다

alert()  // 알림창을 띄운다

confirm() //확인 취소창 (확인은 true,취소는 false반환)

<input type=button value=함수호출 onclick=aa()> // 버튼을 클릭하면 aa()함수를 호출한다

i=parseInt(변수)//문자열을 정수로 정수로변환

OnClick  // 마우스 클릭했을때

OnMouseOver //마우스가 올라왔을때

OnMouseOut // 마우스가 나갔을때

OnLoad  //페이지 시작시 실행한다 body에만 사용가능
ex)<body OnLoad=메서드명>

OnUnload // 페이지에서 나갔을때 body에만 사용가능
ex)
<body OnUnload=메서드명>

OnChange //값을 변경했을때

OnBlur  // 커서제거시 실행 (focus를 잃었을때)

OnFocus // 커서가 있을시 focus가 들어가면실행

document.myform.pwd.value=""; //myform의 pwd에 내용삭제

document.myform.pwd.focus(); //myform의 pwd에 포커스를 맞춘다

*******************************************************************
<form name=myform>
<select name=job>
  <option selected>직업선택
   <option value=학생>학생
   <option value=회사원>회사원
   <option value=자영업>자영업
   <option value=백수>백수
   <option value=프로그래머>프로그래머
   <option value=주부>주부
   <option value=기타>기타
</select>

document.myform.job.options[i].text //i번째 text를 반환

document.myform.job.options[i].text.value //i값을얻는다

document.myform.job.options[i].text.selected //i선택돼었는가

document.myform.job.options.selectedIndex //선택한 위치를 얻는다

document.myform.job.options.length  //option배열 길이갯수반환

********************************************************************

스크립트의 배열
Sum=new Array(100,”kim”,188,9) 형에상관없이 하나의배열에 정수 실수 문자 모두가능

window.open("열릴주소이름or파일이름","새창이름","속성"); //새창을연다
속성의종류
menubar=yes  //메뉴바
scrollbars=yes  //스크롤바
resizable=yes  //창크기재설정
toolbar=yes  //툴바
status=yes //상태바
width=600  //폭
height=600 //높이

window.close();//창닫기

<a href=javascript:window.close()>닫기</a> //창닫기

<a href=javascript:self.close()>닫기</a> //창닫기

today=new Date(); //시스템날짜구하기
getYear()  //년도
getMonth() //월(0~11월이므로 표기시 +1)
getDate() //일
getDay()  //요일(일요일0 월1 토6)
getHours()  //시간
getMinutes() //분
getSeconds()  //초

window.status= //윈도우상태창설정

setTime(명령어,밀리초); //1초후에 명령어실행

setInterval(명령어,밀리초); //1초마다 명령어실행

location.replace(url);  // 지정 url로 대체(back)안됨

location.herf="url"  // back 가능

location.reload() // 새로고침

---------------------------------------

추가

var str = "test,123,test333".split(","); // ,단위로 나누어 배열저장

var str = "niee@naver.com".indexOf("@") //@의 문자열위치반환

var str = "niee@naver.com".substr(start,end); //start~end위치의 문자열반환첫문자의 위치는0번

var num = "123123123".replace("1","ee"); //1이라는 숫자가나오면 ee로변환 첫번째탐색되는1만해당

var num = "123123123".replace(new RegExp("1","g"),"ee"); //모든1을 ee로변환

[출처] 자바스크립트 명령어들|작성자 niee

Posted by 다오나무
2011. 11. 3. 09:54

JavaScript

a free online quick reference order here VisiBone
JavaScript Numbers (section of the JavaScript Card and Foldouts)
I hope you find these 
excerpts of VisiBone
JavaScript references
very useful.

Contents:
Number
String
Number <–> String
Boolean
Date
Math

Array
Function
logic
Object
type
object-orientation
Error (exceptions)
LEGEND
Operator Precedence

More content is in the
product closeups, especially:
DOM (Document 
Object Model)
Regular Expressions

The information here 
is part of two printed
references, that
VisiBone makes, the
JavaScript Card:
JavaScript Card

a dense, laminated,
four-page 8.5x11 book

and also the
JavaScript Foldouts:
JavaScript Language Foldout JavaScript DOM Foldout JavaScript Regular Expressions Foldout
a set of three fan-fold
booklets with larger
print and smaller
folded size.

JavaScript Strings (section of the JavaScript Card and Foldouts)
Does it look busy?
Well, it wasn't meant
for idle people!

Here are all the
features of client-side
JavaScript, in
living code.

English takes a
back seat here.  
To make solid 
code, learn to 
read, think and 
write in
JavaScript.
Fluency will
serve you best
in the end.

The assert()
function is the best
invention for
programming
since the subroutine.

Not only will its
proper use make
your software
test itself, earning
and protecting
reliability from the
start.

But it's a clear,
concise way to
describe exactly
what all the features
of JavaScript do.

Did I mention?
Feedback 
form below!

Regular Expressions
are very versatile for
validating or
analyzing strings.

See the JavaScript
Regular Expressions
reference.
If you are looking to
establish or extend
your business in
international markets,
it is very important to
ground your company's
brand and presence in
targeted countries. The
first step in a successful
strategy is to register
an international domain
for your company.
International domain
registration can be
tricky, so use a
registrar that knows
the requirements and
process is important.
Check out godaddy
for the widest selection
and best prices on
international domains.

JavaScript Number / String conversion (section of the JavaScript Card and Foldouts)

JavaScript Boolean (section of the JavaScript Card and Foldouts)

JavaScript Dates (section of the JavaScript Card and Foldouts)
The assert() function
is like a video camera. 
Hold on now, this will 
make sense in a sec.

Think how you first learn 
human language. You 
observe words spoken 
and their effects. 
Person A: "I'm hungry" 
Person B gives A food. 
You infer an association 
between making the 
sound "hungry" and 
getting fed.

This card can teach you 
JavaScript not by talking 
about it but by doing it 
and (here's the part I'm 
smug about) showing 
you the effects. The 
assert() function is a 
great way of showing 
you what JavaScript 
code does.

Imagine, instead of a 
dead-tree dictionary 
that defines words in 
terms of ... other words, 
it would instead show 
a video clip of people 
using and responding
to
those words.

Assert makes the 
effects of JavaScript 
code visible, just like 
this video-dictionary 
would make the 
effects of human 
words visible.

JavaScript Math (section of the JavaScript Card and Foldouts)
JavaScript Arrays (section of the JavaScript Card and Foldouts)

JavaScript Functions (section of the JavaScript Card and Foldouts)

JavaScript Programming Logic (section of the JavaScript Card and Foldouts)

VisiBone also makes
several printed web
color references.

Posters & Charts
Webmaster's Palette Color Wheel Poster

Laminated Cards
Color Card, laminated and slick for clients
that match the 
"VisiBone2"
swatch collection 
in Adobe
Illustrator and 
Photoshop.

Plus two varieties 
of Mouse Pads.

And a chart with 
1068
non-web-safe
colors:
Web Color KiloChart
Guaranteed compatible
with walls in Asia,
Europe, the Americas,
Africa, Australia and
California.

JavaScript Objects (section of the JavaScript Card and Foldouts)

JavaScript Types (section of the JavaScript Card and Foldouts)

JavaScript Object Oriented Programming (section of the JavaScript Card and Foldouts)

JavaScript Exceptions (section of the JavaScript Card and Foldouts)
Legend (section of the JavaScript Card and Foldouts)
Thank you, and good luck building!

JavaScript Reference Contents:
Number
String
Number <–> String
Boolean
Date
Math

Array
Function
logic
Object
type
object-orientation
Error (exceptions)
LEGEND

Here's a table of Browsers versus the JavaScript versions they claim to support:

        
         
                IE   IE   IE   IE  IE  IE  IE  IE
                PC   Mac  PC   PC  Mac Mac PC  PC    Netscape   Mozilla   Opera
                4.01 4.01 4.01 5.0 5.0 5.1 5.5 6     4.7  6.0   0.9-1.0   6.03

JavaScript      X    X    X    X   X   X   X   X     X    X        X      X
JavaScript1.0   X    X    X    X   X   X   X   X     X    X        X      X

JavaScript1.1   X    X    X    X   X   X   X   X     X    X        X      X
JavaScript1.2   X    X    X    X   X   X   X   X     X    X        X      X
JavaScript1.3             X    X   X   X   X   X     X    X        X      X
JavaScript1.4                      X   X                  X        X      X
JavaScript1.5                                             X        X

Jscript         X    X    X    X   X   X   X   X

EcmaScript                X    X           X   X                          X

exceptions      no   no   yes  yes yes yes yes yes   no   yes     yes     yes
supported?


An "X" in row "Yyyyy" means code under <script language="Yyyyy"> will run
in the browser for that column.  For example:

     IE6/PC
     ------
     <script language="JavaScript 1.3">
          // runs
     </script>

     Netscape 6
     ----------
     <script language="EcmaScript">
          // ignored
     </script>

(Yes, there are two radically different browsers both claiming to be IE4.01,
one claims to support JavaScript 1.3 and EcmaScript, and exceptions work
perfectly, and the other not.)

See the Error section for a trick on how to include code with exceptions.


        
      
Posted by 다오나무