encodeURIComponent() 함수는 URI를 나타내는 문자열 값을 받아들이고 숫자(1에서 4까지)와 이스케이프 시퀀스를 사용하여 그 안에 있는 문자를 교체하여 인코딩합니다.
구문
구문은 다음과 같습니다.
encodeURIComponent('https://www.qries.com/'); 예시
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var result1 = encodeURIComponent('https://www.qries.com/');
document.write(result1);
document.write("<br>");
var result2 = encodeURIComponent('https://www.tutorialspoint.com/');
document.write(encodeURIComponent(result2));
</script>
</body>
</html> 출력
http%3A%2F%2Fwww.qries.com%2F http%253A%252F%252Fwww.tutorialspoint.com%252F