-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathex2.html
More file actions
55 lines (49 loc) · 1.45 KB
/
ex2.html
File metadata and controls
55 lines (49 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE>
<head>
<meta charset='utf-8'>
<title>ex2</title>
</head>
<script>
function onConnect() {
var hostName = document.getElementById('host-name').value;
if(hostName == '') {
alert('호스트를 입력하십시오.');
return;
}
var userId = document.getElementById('user-id').value;
if(userId == '') {
alert('사용자 아이디를 입력하십시오.');
return;
}
var password = document.getElementById('password').value;
if(password == '') {
alert('비밀번호를 입력하십시오.');
return;
}
var encodedData = window.btoa(userId + ':' + password); // base64 인코딩
var src = (hostName.includes('http://', 0) ? '' : 'http://') +
hostName + '/watch?ch=1&auth=' + encodedData;
document.getElementById('result').innerText = src;
document.getElementById('player').src = src;
}
</script>
<body>
<h2>예제2. 실제 서버에 접속하기</h2>
<table>
<tr>
<td>호스트</td>
<td>사용자 아이디</td>
<td>비밀번호</td>
</tr>
<tr>
<td><input type='text' id='host-name'></td>
<td><input type='text' id='user-id'></td>
<td><input type='text' id='password'></td>
<td><button type='button' onClick='onConnect()'>접속</button> </td>
</tr>
<tr>
<td colspan='4' id='result'></td>
</tr>
</table>
<iframe width='640' height='360' frameborder='0' allowfullscreen id='player' />
</body>