-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
150 lines (139 loc) · 5.05 KB
/
index.html
File metadata and controls
150 lines (139 loc) · 5.05 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Split Iframes with Homepage Buttons</title>
<style>
body {
margin: 0;
display: grid;
grid-template-rows: 1fr 1fr;
grid-template-columns: 1fr 1fr;
height: 100vh;
overflow: hidden;
}
.iframe-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
border: 1px solid #ccc;
padding: 10px;
box-sizing: border-box;
}
.iframe-container.active {
border: 2px solid #00f;
}
iframe {
width: 100%;
height: 100%;
border: none;
}
.controls {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.controls input {
flex: 1;
padding: 5px;
font-size: 16px;
margin-right: 10px;
}
.controls button {
padding: 5px 10px;
font-size: 16px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="iframe-container active" id="container1">
<div class="controls">
<input type="text" id="url1" placeholder="Enter URL">
<button onclick="navigate('iframe1', 'url1')">Go</button>
<button onclick="goHome('iframe1')">Homepage</button>
</div>
<iframe src="https://www.google.com/webhp?igu=1" id="iframe1"></iframe>
</div>
<div class="iframe-container" id="container2">
<div class="controls">
<input type="text" id="url2" placeholder="Enter URL">
<button onclick="navigate('iframe2', 'url2')">Go</button>
<button onclick="goHome('iframe2')">Homepage</button>
</div>
<iframe src="https://www.google.com/webhp?igu=1" id="iframe2"></iframe>
</div>
<div class="iframe-container" id="container3">
<div class="controls">
<input type="text" id="url3" placeholder="Enter URL">
<button onclick="navigate('iframe3', 'url3')">Go</button>
<button onclick="goHome('iframe3')">Homepage</button>
</div>
<iframe src="https://www.google.com/webhp?igu=1" id="iframe3"></iframe>
</div>
<div class="iframe-container" id="container4">
<div class="controls">
<input type="text" id="url4" placeholder="Enter URL">
<button onclick="navigate('iframe4', 'url4')">Go</button>
<button onclick="goHome('iframe4')">Homepage</button>
</div>
<iframe src="https://www.google.com/webhp?igu=1" id="iframe4"></iframe>
</div>
<script>
let activeContainerId = 'container1';
function goHome(iframeId) {
const iframe = document.getElementById(iframeId);
iframe.src = "https://www.google.com/webhp?igu=1";
}
function navigate(iframeId, inputId) {
const url = document.getElementById(inputId).value;
if (url) {
const iframe = document.getElementById(iframeId);
iframe.src = url.startsWith('http://') || url.startsWith('https://') ? url : `https://${url}`;
}
}
function setActiveContainer(newActiveId) {
document.getElementById(activeContainerId).classList.remove('active');
document.getElementById(newActiveId).classList.add('active');
activeContainerId = newActiveId;
}
document.addEventListener('keydown', (event) => {
const key = event.key.toLowerCase();
const ctrl = event.ctrlKey;
const order = ['container1', 'container2', 'container3', 'container4'];
let currentIndex = order.indexOf(activeContainerId);
if (ctrl) {
if (key === 'h' || event.key === 'ArrowLeft') {
currentIndex = (currentIndex - 1 + order.length) % order.length;
} else if (key === 'l' || event.key === 'ArrowRight') {
currentIndex = (currentIndex + 1) % order.length;
} else if (key === 'k' || event.key === 'ArrowUp') {
currentIndex = (currentIndex - 2 + order.length) % order.length;
} else if (key === 'j' || event.key === 'ArrowDown') {
currentIndex = (currentIndex + 2) % order.length;
}
setActiveContainer(order[currentIndex]);
}
});
document.querySelectorAll('.iframe-container').forEach(container => {
container.addEventListener('click', () => {
setActiveContainer(container.id);
});
container.addEventListener('focusin', () => {
setActiveContainer(container.id);
});
});
// Add event listener to each iframe to set active container when clicked
document.querySelectorAll('iframe').forEach(iframe => {
iframe.addEventListener('click', () => {
const containerId = iframe.closest('.iframe-container').id;
setActiveContainer(containerId);
});
});
</script>
</body>
</html>