forked from kasmtech/noVNC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_iframe.html
129 lines (119 loc) · 4.18 KB
/
example_iframe.html
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html>
<head>
<style>
/* Container to maintain aspect ratio and full width */
.vnc-container {
position: relative;
width: 100%;
height: 80vh;
overflow: hidden;
}
/* Responsive iframe styling */
.vnc-iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}
/* Alternative fixed size container */
.vnc-container-fixed {
position: relative;
width: 1280px;
height: 800px;
margin: 0 auto;
}
.flex {
display: flex;
justify-content: center;
align-items: center;
}
button {
padding: 10px 15px;
border: none;
border-radius: 4px;
background-color: #2563eb;
color: white;
cursor: pointer;
transition: background-color 0.2s;
}
button:hover {
background-color: #1d4ed8;
}
</style>
</head>
<body>
<!-- Responsive full-screen implementation -->
<div class="flex">
<button onclick="sendMessage('show_panel')">Show Panel</button>
<button onclick="sendMessage('hide_panel')">Hide Panel</button>
<button onclick="sendMessage('open_clipboard')">Open Clipboard</button>
<button onclick="sendMessage('close_clipboard')">Close Clipboard</button>
<button onclick="sendMessage('open_displays_mode')">Open Displays</button>
<button onclick="sendMessage('close_displays_mode')">Close Displays</button>
<button onclick="sendMessage('resize')">Resize</button>
<button onclick="sendMessage('set_perf_stats', true)">Show Stats</button>
<button onclick="sendMessage('set_perf_stats', false)">Hide Stats</button>
</div>
<div class="vnc-container">
<!--src="vnc.html#show_control_bar=true" to show control bar-->
<iframe
id="vnc-iframe"
src="vnc.html"
class="vnc-iframe"
allow="clipboard-read; clipboard-write; fullscreen"
allowfullscreen="true"
sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals"
></iframe>
</div>
<script>
// Function to send messages to the VNC iframe
function sendMessage(action, value = null) {
const message = { action };
if (value !== null) {
message.value = value;
}
// Get the iframe element - adjust the selector as needed
const vncIframe = document.querySelector('#vnc-iframe');
if (vncIframe) {
vncIframe.contentWindow.postMessage(message, '*');
} else {
console.error('VNC iframe not found');
}
}
// Function to set custom resolution
function setResolution() {
const resX = parseInt(document.getElementById('resX').value);
const resY = parseInt(document.getElementById('resY').value);
if (resX > 0 && resY > 0) {
sendMessage('set_resolution', {
value_x: resX,
value_y: resY
});
} else {
alert('Please enter valid resolution values');
}
}
// Function to set video quality
function setVideoQuality() {
const quality = parseInt(document.getElementById('quality').value);
if (quality >= 0 && quality <= 9) {
sendMessage('setvideoquality', { value: quality });
} else {
alert('Please enter a quality value between 0 and 9');
}
}
// Function to set idle timeout
function setIdleTimeout() {
const timeout = parseInt(document.getElementById('idleTimeout').value);
if (timeout >= 0) {
sendMessage('set_idle_timeout', timeout);
} else {
alert('Please enter a valid timeout value');
}
}
</script>
</body>
</html>