-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
83 lines (74 loc) · 2.01 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Web Browser</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
#navbar {
display: flex;
padding: 10px;
background-color: #f1f1f1;
}
#urlInput {
flex: 1;
padding: 10px;
font-size: 16px;
}
button {
padding: 10px;
margin-left: 5px;
}
#webview {
width: 100%;
height: 80vh;
border: none;
}
</style>
</head>
<body>
<div id="navbar">
<input type="text" id="urlInput" placeholder="Enter URL" />
<button onclick="navigate()">Go</button>
<button onclick="goBack()">Back</button>
<button onclick="goForward()">Forward</button>
<button onclick="reload()">Reload</button>
</div>
<iframe id="webview" src="https://www.google.com"></iframe>
<script>
const iframe = document.getElementById('webview');
const urlInput = document.getElementById('urlInput');
function navigate() {
let url = urlInput.value;
if (!url.startsWith('http://') && !url.startsWith('https://')) {
url = 'http://' + url;
}
iframe.src = url;
}
function goBack() {
// Basic back functionality (not full history)
if (iframe.contentWindow.history.length > 1) {
iframe.contentWindow.history.back();
}
}
function goForward() {
// Basic forward functionality (not full history)
if (iframe.contentWindow.history.length > 1) {
iframe.contentWindow.history.forward();
}
}
function reload() {
iframe.src = iframe.src;
}
// Update the URL input field when navigating
iframe.onload = function() {
urlInput.value = iframe.src;
};
</script>
</body>
</html>