Spaces:
Running
Running
| <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> |