Spaces:
Running
Running
File size: 5,508 Bytes
5ca8917 | 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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Split View Browser</title>
<style>
body {
margin: 0;
padding: 0;
height: 100vh;
overflow: hidden;
font-family: Arial, sans-serif;
}
.split-container {
display: flex;
width: 100%;
height: 100vh;
}
.frame-container {
position: relative;
height: 100%;
overflow: hidden;
}
.frame {
width: 100%;
height: 100%;
border: none;
}
.splitter {
width: 8px;
background: #ddd;
cursor: col-resize;
transition: background 0.2s;
}
.splitter:hover {
background: #bbb;
}
.url-input-container {
position: absolute;
top: 0;
left: 0;
right: 0;
padding: 8px;
background: rgba(255, 255, 255, 0.9);
display: flex;
z-index: 10;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.url-input {
flex: 1;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
margin-right: 8px;
}
.go-button {
padding: 8px 16px;
background: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.go-button:hover {
background: #45a049;
}
</style>
</head>
<body>
<div class="split-container">
<div class="frame-container" id="left-container">
<div class="url-input-container">
<input type="text" class="url-input" id="left-url" placeholder="Enter URL for left frame (e.g., https://example.com)">
<button class="go-button" onclick="loadFrame('left')">Go</button>
</div>
<iframe class="frame" id="left-frame"></iframe>
</div>
<div class="splitter" id="splitter"></div>
<div class="frame-container" id="right-container">
<div class="url-input-container">
<input type="text" class="url-input" id="right-url" placeholder="Enter URL for right frame (e.g., https://example.com)">
<button class="go-button" onclick="loadFrame('right')">Go</button>
</div>
<iframe class="frame" id="right-frame"></iframe>
</div>
</div>
<script>
// Initialize splitter functionality
const splitter = document.getElementById('splitter');
const leftContainer = document.getElementById('left-container');
const rightContainer = document.getElementById('right-container');
let isDragging = false;
splitter.addEventListener('mousedown', function(e) {
isDragging = true;
document.body.style.cursor = 'col-resize';
document.addEventListener('mousemove', onMouseMove);
document.addEventListener('mouseup', onMouseUp);
});
function onMouseMove(e) {
if (!isDragging) return;
const containerWidth = document.querySelector('.split-container').offsetWidth;
const leftWidth = e.clientX - splitter.offsetWidth / 2;
const rightWidth = containerWidth - leftWidth - splitter.offsetWidth;
leftContainer.style.width = leftWidth + 'px';
rightContainer.style.width = rightWidth + 'px';
}
function onMouseUp() {
isDragging = false;
document.body.style.cursor = '';
document.removeEventListener('mousemove', onMouseMove);
document.removeEventListener('mouseup', onMouseUp);
}
// Set initial split (50/50)
function initializeSplit() {
const containerWidth = document.querySelector('.split-container').offsetWidth;
const splitWidth = (containerWidth - splitter.offsetWidth) / 2;
leftContainer.style.width = splitWidth + 'px';
rightContainer.style.width = splitWidth + 'px';
}
// Load URL into frame
function loadFrame(side) {
const urlInput = document.getElementById(`${side}-url`);
const frame = document.getElementById(`${side}-frame`);
let url = urlInput.value.trim();
// Add https:// if not present
if (url && !url.match(/^https?:\/\//)) {
url = 'https://' + url;
}
if (url) {
frame.src = url;
}
}
// Initialize on load
window.addEventListener('load', function() {
initializeSplit();
// Load default pages if needed
// document.getElementById('left-url').value = 'https://example.com';
// document.getElementById('right-url').value = 'https://example.org';
// loadFrame('left');
// loadFrame('right');
});
// Handle window resize
window.addEventListener('resize', initializeSplit);
</script>
</body>
</html> |