문서 주소의 제일 앞에 나오는 콜론(:)까지의 송신 방식을 나타내는 문자열 정보를 반환하거나 설정한다.
![]() | Script | [sVal=]object.protocol |
HTML | 없음 |
연결 개체의 이름이다.
이 속성은 읽기/쓰기이며 디폴트값은 없다.
protocol 속성은 문서의 송신방법을 나타내는 문자열로 문서의 제일 처음 부분으로 콜론(:)까지를 포함하며,
http:, ftp;, mailto:등으로 아래와 같다.
URL type | Protocol | 예제 |
---|---|---|
Navigator info | about: | about:cache |
File | file:/ | file:///javascript/methods.html |
FTP | ftp: | ftp://ftp.mine.com/home/mine |
Gopher | gopher: | gopher.myhost.com |
World Wide Web | http: | http://home.netscape.com/ |
JavaScript code | javascript: | javascript:history.go(-1) |
MailTo | mailto: | mailto:info@netscape.com |
Usenet | news: | news://news.scruznet.com/comp.lang.javascript |
Navigator source viewer | view-source: | view-source:wysiwyg://0/file:/c|/temp/genhtml.html |
protocol 속성은 정보를 호스트에서 사용자에게 어떻게 송신하는가를 정의한다.
http와 ftp protocol이 가장 많이 사용되고 브라우저는 다른 미리 정의된 프로토콜들을 지원한다.
document, img와 location 개체에서는 protocol 속성이 읽기전용이다.
location.protocol 속성은 주소의 앞쪽 문자열을 첫번째 콜론(:)까지를 포함하여 반환한다.(예: http:).
반면 document.protocol은 프로토콜 약어를 반환한다.(예: Hypertext Transfer Protocol을 http로)
protocol 속성은 언제나 설정이 가능하지만, href 속성으로 연결을 새로 설정하여 사용하는 것이 안전하다.
개체 | script | HTML | 규격 | IE |
---|---|---|---|---|
a | [sVal=]a.protocol | 없음 | 없음 | IE3.02(win16,win32,mac),IE4.0(ce,unix) |
area | [sVal=]area.protocol | 없음 | 없음 | IE3.02(win16,win32,mac),IE4.0(ce,unix) |
document | [sVal=]document.protocol | 없음 | 없음 | IE3.02(win16,win32,mac),IE4.0(ce,unix) |
img | [sVal=]img.protocol | 없음 | 없음 | IE4.0(win16,win32,ce,unix,mac) |
link | [sVal=]link.protocol | 없음 | 없음 | |
location | [sVal=]location.protocol | 없음 | 없음 | IE3.02(win16,win32,mac),IE4.0(ce,unix) |
참조 | protocol 속성 | host 속성 | hostname 속성 | port 속성 | pathname 속성 | hash 속성 | target 속성 |
search속성 | href 속성 | URL 속성 | domain 속성 | document 개체 |
![]() | protocol 속성⇒ | ![]() | ![]() ![]() ![]() |
<A href="http://trio.co.kr/cgi/bbs/triobbs.cgi?db=triobbs">trio 게시판</A><BR> <SCRIPT> for (i=0;i<document.links.length;i++){ if(document.links[i].hostname=='trio.co.kr') document.write(document.links[i].href+'<BR><FONT color=blue>'+document.links[i].protocol+'</FONT><BR>'); } </SCRIPT>
<SCRIPT> document.write('document.location.protocol=<FONT color=blue>'+document.location.protocol+'</FONT><BR>'); document.write('location.protocol=<FONT color=blue>'+location.protocol+'</FONT><BR>'); document.write('document.protocol=<FONT color=blue>'+document.protocol+'</FONT><BR>'); </SCRIPT>
<SCRIPT> function allProtocol(){ allLinks=document.links; str='allLinks.length='+allLinks.length+'<BR>'; for (i=0;i<ALLLINKS.length;i++){ if (!allLinks[i].protocol) return; str+='allLinks['+i+'].protocol='+allLinks[i].protocol+'<BR>'; } showA.innerHTML=str; } </SCRIPT> <BUTTON onclick=allProtocol()>페이지의 프로토콜 모두 보기</BUTTON> <DIV id=showA>결과 표시창</DIV>
![]() | protocol 속성 | ⇒ | ![]() ![]() |
최종 수정: 07/09/2025 13:05:40 | ![]() All right reserved | 비정상적인 방식으로 프레임없이 페이지에 접속하면 자주 오류가 발생됩니다. 오류가 나면 정상적 접속으로 시도해 보세요. | http://koxo.com/lang/js/property/protocol.html |